popsin has asked for the wisdom of the Perl Monks concerning the following question:
But it doesn't work what I expect. I get all rows with the same values as in the last row read from the text file. This is what I get when I check the @loop array:foreach $line (@lines) { ($name, $value) = split(/=/, $line); chomp($name); chomp($value); if ($name eq "loop" and $value eq "start") { $loop_status = "start"; } if ($loop_status eq "start") { if ($name eq "loop_name") { $loop_name = $value; } elsif ($name eq "loop" and $value eq "end") { $loop_status = "end"; $template->param(eval "$loop_name" => \@loop); } elsif ($name eq "row" and $value eq "start") { my %row; } elsif ($name eq "row" and $value eq "end") { push (@loop, \%row); } else { if ($name ne "loop") { $row{eval "$name"} = $value; } } } if ($loop_status ne "start") { if ($name ne "loop" and $name ne "loop_name" and $name ne "row" an +d $name { $template->param($name, $value); } } }
It seems that it does not create new hash %row when it goes through the loop.$VAR1 = [ { 'rel_date' => '04/060/09', 'importer' => 'Something', 'file_id' => '123', 'vendor' => 'Some', 'urgency' => '5' }, $VAR1->[0], $VAR1->[0], $VAR1->[0], $VAR1->[0] ];
Any suggestions?
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: adding a new hash in an array
by matija (Priest) on Jul 14, 2004 at 16:40 UTC | |
by popsin (Initiate) on Jul 14, 2004 at 20:34 UTC | |
by friedo (Prior) on Jul 15, 2004 at 00:06 UTC | |
|
Re: adding a new hash in an array
by Roy Johnson (Monsignor) on Jul 14, 2004 at 16:39 UTC |