Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: adding a new hash in an array

by popsin (Initiate)
on Jul 14, 2004 at 20:34 UTC ( #374431=note: print w/ replies, xml ) Need Help??


in reply to Re: adding a new hash in an array
in thread adding a new hash in an array

Thanks,

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?


Comment on Re^2: adding a new hash in an array
Download Code
Re^3: adding a new hash in an array
by friedo (Prior) on Jul 15, 2004 at 00:06 UTC
    I tried to put use strict but I got the whole bunch of error messages so I will skip it.

    That's the whole point of use strict. Those error messages are telling you why your code is broken. You would never have run into the problem you just had if your code was strict-compliant.

    Is there a standard way to store session variables?

    Indeed. Check out CGI::Session.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://374431]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-12-25 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (162 votes), past polls