perlquestion
rattusillegitimus
<p>I've been playing around with nested <code><TMPL_LOOP></code> structures in
[CPAN://HTML::Template] and I've run into some trouble. I have a hash with
over 40 keys, and I want to turn it into a set of HTML tables like this:</p>
<table border="1">
<tr>
<th>key</th>
<td>key1</td>
<td>key2</td>
<td>key3</td>
<td>key4</td>
<td>key5</td>
</tr>
<tr>
<th>value</th>
<td>val1</td>
<td>val2</td>
<td>val3</td>
<td>val4</td>
<td>val5</td>
</tr>
</table>
<table border="1">
<tr>
<th>key</th>
<td>key6</td>
<td>key7</td>
<td>key8</td>
<td>key9</td>
<td>key10</td>
</tr>
<tr>
<th>value</th>
<td>val6</td>
<td>val7</td>
<td>val8</td>
<td>val9</td>
<td>val10</td>
</tr>
</table>
<p>Each table should be no more than 6 cells wide, including the
<code><th></code>'s. I've got the HTML template defined as follows:</p>
<code><TMPL_LOOP NAME=TABLE>
<table>
<tr>
<th>key</th>
<TMPL_LOOP NAME=KEYCELL>
<td><TMPL_VAR NAME=KEY></td>
</TMPL_LOOP>
</tr>
<tr>
<th>key</th>
<TMPL_LOOP NAME=VALCELL>
<td><TMPL_VAR NAME=VAL></td>
</TMPL_LOOP>
</tr>
</table>
</TMPL_LOOP>
</code>
<p>My problem is that I can't for the life of me wrap my head around how to
build the array to pass in the <code>$template->param(TABLE => [ @array ])</code> line of
my script. Any help with this would be greatly appreciated.</p>
<p>-rattus<br><tt>__________</tt><br>
He seemed like such a nice guy to his neighbors /
Kept to himself and never bothered them with favors<br>
- Jefferson Airplane, "Assassin"</p>