in reply to Re^2: Using arrays as elements in hash
in thread Using arrays as elements in hash
You right. You missed something. Here small part from HTML::Template docs:
The <TMPL_LOOP> tag is a bit more complicated than <TMPL_VAR>. The <TMPL_LOOP> tag allows you to delimit a section of text and give it a name. Inside this named loop you place <TMPL_VAR>s. Now you pass to param() a list (an array ref) of parameter assignments (hash refs) for this loop. The loop iterates over the list and produces output from the text block for each pass. Unset parameters are skipped. Here's an example:
In the template:
<TMPL_LOOP NAME=EMPLOYEE_INFO>
Name: <TMPL_VAR NAME=NAME>
Job: <TMPL_VAR NAME=JOB>
</TMPL_LOOP>
In the script:
$template->param(EMPLOYEE_INFO => [ { name => 'Sam', job => 'progra +mmer' }, { name => 'Steve', job => 'soda + jerk' }, ] ); print $template->output();
So you need array of hashes. If you show more code we can help you.
As Fletch suggest you need
$template->param( 'HTMLloop' => \@array ); or $template->param( 'HTMLloop' => [ @array ] );
Where @array consists of hash refs.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Using arrays as elements in hash
by XMas (Initiate) on Oct 31, 2007 at 09:13 UTC | |
by Gangabass (Vicar) on Nov 01, 2007 at 03:22 UTC | |
by XMas (Initiate) on Nov 01, 2007 at 04:54 UTC |