Me said:
How do I contruct an array of hash references( or arrays) such that
I can have the following loops in html-template:
<MAIN_LOOPP>
DATA1
DATAN
<OTHER-LOOP>
O-DATA1
O-DATAN
</OTHER-LOOP>
</MAIN_LOOP>
Assuming you're talking about HTML::Template, the above is not a valid
template file. Perhaps you intended something like this?
<TMPL_LOOP name="main_loop">
<TMPL_VAR name="data">
<TMPL_LOOP name="other_loop">
<TMPL_VAR name="o_data">
</TMPL_LOOP>
</TMPL_LOOP>
In that case, you would construct your data structure like so
[untested]:
my @main_loop = (
{
data=>'data_1',
other_loop => [
o_data => 'o_data1_1',
o_data => 'o_data1_2',
# . . .
o_data => 'o_data1_n',
],
},
{
data=>'data_2',
other_loop => [
o_data => 'o_data2_1',
o_data => 'o_data2_2',
# . . .
o_data => 'o_data2_n',
],
},
# . . .
{
data=>'data_n',
other_loop => [
o_data => 'o_datan_1',
o_data => 'o_datan_2',
# . . .
o_data => 'o_datan_n',
],
},
);
$tmpl->param('main_loop' => \@main_loop);
If I have incorrectly interpreted your request, please post a
short-but-complete *actual* template file that you wish to fill, and
your Perl code that attempts to fill it.
Paul Lalli