in reply to Populating an Array of hash's
The file names are the keys in your code, but you're printing the values.
But HTML::Template doesn't want a hash, it wants an array of records, where each record is a hash. In this case, the record only has one field, the file name.
<TMPL_LOOP NAME=FILES> Name: <TMPL_VAR NAME=NAME><br> </TMPL_LOOP>
$template->param( FILES => [ map +{ NAME => $_ }, @files ], );
If you also want a number, just add a field to the hash.
<TMPL_LOOP NAME=FILES> <TMPL_VAR NAME=NUM>. <TMPL_VAR NAME=NAME><br> </TMPL_LOOP>
$template->param( FILES => [ map +{ NUM => $_+1, NAME => $files[$_], }, 0..$#files ], );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Populating an Array of hash's
by tinita (Parson) on Oct 02, 2008 at 10:14 UTC | |
|
Re^2: Populating an Array of hash's
by ianand0204 (Initiate) on Oct 01, 2008 at 15:47 UTC | |
by ikegami (Patriarch) on Oct 02, 2008 at 02:13 UTC |