This is the code that works:
my @arr; my $loop_status; my $loop_name; MAINLOOP: foreach $line (@lines) { ($name, $value) = split(/=/, $line); chomp($name); chomp($value); if ($name eq "loop" and $value eq "start") { $loop_status = "start"; next MAINLOOP; } if ($name eq "loop_name") { $loop_name = $value; next MAINLOOP; } if ($name eq "loop" and $value eq "stop") { $loop_status = "stop"; $template->param(eval "$loop_name" => \@arr); next MAINLOOP; } if ($loop_status eq "start") { if ($name eq "row" and $value eq "start") { $cnt++; push(@arr,{}); next MAINLOOP; } $arr[$cnt]{eval "$name"} = $value; } else { $template->param($name, $value); } } print "Content-type: text/html\n\n"; print $template->output;
I know my code is a mess :-(
But it works fine now.
I tried to put use strict but I got the whole bunch of error messages so I will skip it.
Another question:
Is there a standard way to store session variables?
In reply to Re^2: adding a new hash in an array
by popsin
in thread adding a new hash in an array
by popsin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |