Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with multiple use of special variable $/

Status
Not open for further replies.

cwoldsen

Programmer
Nov 5, 2002
3
FR
Hi all,
I need to parse two different xml files and separate the paragraphs as record using the input record separator $/.Problem is that the records end differenty and I don't know how to set $/ twice with different values as I need it.
Doing it as below won't work. Does anybody have a good advice?

$/ = '</filea>';
while (<INA>){
$ina = $_;
chomp ($ina);
if ($ina =~.......etc
$/ = '</fileb>';
while (<INB>) {
$inb = $_;
chomp ($inb);
if ($inb =~.......etc
 
I think that saying

if ($ina =~.......etc
my$/ = '</fileb>';

will solve your problem.

I haven't tried this mind you :) Mike

&quot;Experience is the comb that Nature gives us, after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Mike,
thanks for your reply but it's not possible to set a global variable to 'my' ;-( so this didn't help me...
 
ah.. ok

local() ? Mike

&quot;Experience is the comb that Nature gives us, after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
wasn't obvious with my code here, but there's a while loop inside another while loop.
Have tried local() already within each while loop.Problem again (I guess) that one local $/ overlays the second one because they're actually both within the same block,so it won't do (am I right?). If both set to local Perl takes in my entire second file as record, not the lines itself...;-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top