Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Can anyone tell me how to change a hash in order for it to be fed to a <TMPL_LOOP> within HTML::Template? Here is what I am doing:
This happens several times, and then I have a large hash. Do I need to put this into an array and assign it names? I tried the code below:$img_number = $1; $img_user = $2; $hash{$img_number} = $img_user;
and it didn't work. It gave the following error:my @loop_data = (); push(@loop_data, \%hash); my $template = HTML::Template->new(filename => 'fun.tmpl'); my $CGI = CGI->new(); $template->param(template_loop => \@loop_data); print $CGI->header( ); print $CGI->title("Here is your output."); print $template->output; exit;
HTML::Template->output() : fatal error in loop output : HTML::Template + : Attempt to set nonexistent parameter 'URL229' - this parameter nam +e doesn't match any declarations in the template file : (die_on_bad_p +arams => 1) at /usr/share/perl5/HTML/Template.pm line 2789 at /var/www/QQ/funtimes.pl line 171
I am sure that an array is involved, but I dont know how to go from a has to an array. Is this what is needed?
Thank you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A hash to an array for HTML::Template
by jasonk (Parson) on Apr 20, 2005 at 22:29 UTC | |
by bradcathey (Prior) on Apr 21, 2005 at 00:06 UTC | |
|
Re: A hash to an array for HTML::Template
by Cody Pendant (Prior) on Apr 21, 2005 at 00:38 UTC |