in reply to Re: Can't seem to use an AoH with Template::Toolkit
in thread Can't seem to use an AoH with Template::Toolkit

Maybe I've mis-understood you -- I made the code less fancy and used a hash instead of a hashref, as shown below, and got the sme result.

for ( 1..9 ) { my $last = "last_name$_"; my $first = "first_name$_"; my %h; if ( length($vars->{$last}) && length($vars->{$last}) ) { $h{'last_name'} = $vars->{$last}; $h{'First_name'} = $vars->{$first}; } else { # Leave a blank one at the end. $h{'last_name'} = ''; $h{'First_name'} = ''; last; } push ( @reg_array, \%h ); }

I guess I don't understand your answer.

I'm able to get the information from $vars just fine, but it seems putting it back onto the form is a problem.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re^3: Can't seem to use an AoH with Template::Toolkit
by perrin (Chancellor) on Jan 29, 2007 at 14:10 UTC
    In your original code, you get a hashref back from $cgi->Vars, and then you try to put @reg_array into it as if it were a normal hashref. That would work, except that $vars that comes back from $cgi->Vars is not a hashref, but rather a tied variable that CGI generated.

    I can't tell if the code you show here still has that problem because you didn't show that part. If it does, a quick fix would be to change that line where you call $cgi->Vars to this:

    my %vars = $cgi->Vars; my $vars = \%vars;