Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
# I open the file of query strings open (DATABASE, "$Raw_data"); flock(DATABASE, 2); @database=<DATABASE>; flock(DATABASE, 8); close DATABASE; # read each line in foreach $database (@database) { chomp $database; @pairs = split(/&/, $database); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1 +))/eg; $value =~ s/~!/ ~!/g; if ($in{$name}) { $value = $in{$name}.", ".$value; } $in{$name} = $value; } # assign values to variables $NAME=$in{'NAME'}; $AMOUNT=$in{'AMT'}; # print variables to see values print "$NAME - $AMOUNT<br>";
For the test file there were 32 lines. The problem is $NAME and $AMOUNT get larger each time the file is read.
I've tried using a counter and setting up hashes like $NAME[$counter] and $AMT[$counter] but the same thing happens.
I've also tried $NAME = ""; $AMT = ""; at the end to erase any values.
I just need to know how to set the values for $NAME and $AMT to null values each time a line is processed.
Thanks,
Jeri
Edit ar0n 2001-07-22 -- added <code> tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing Query Strings in a file
by wog (Curate) on Jul 23, 2001 at 01:22 UTC | |
|
Re: Parsing Query Strings in a file
by HyperZonk (Friar) on Jul 23, 2001 at 01:08 UTC | |
by Anonymous Monk on Jul 24, 2001 at 04:17 UTC | |
|
Re: Parsing Query Strings in a file
by Anonymous Monk on Jul 23, 2001 at 01:03 UTC | |
|
Re: Parsing Query Strings in a file
by CharlesClarkson (Curate) on Jul 23, 2001 at 00:50 UTC |