Check out (jeffa) Re: Structure for nested html::template loops.

UPDATE:
Here is how i would do it ... this is almost identical to blokhead's answer:

use strict; use HTML::Template; my $html = do{local $/;<DATA>}; my %hash = map { $_ => chr $_ } (97..122); my ($i,$j) = (0,0); my $max = 5; my $table; for (sort keys %hash) { push @{$table->[$j]->{key}},{key => $_}; push @{$table->[$j]->{val}},{val => $hash{$_}}; $j++ unless ++$i % $max; } my $tmpl = HTML::Template->new( scalarref => \$html, ); $tmpl->param( table => $table ); print $tmpl->output; __DATA__ <style type="text/css"> <!-- table { border-style: outset; border-width: thin; } th { border-style: inset; } td { border-style: inset; } --> </style> <tmpl_loop table> <table border="1"> <tr> <th>Key</th> <tmpl_loop key> <td><tmpl_var key></td> </tmpl_loop> </tr> <tr> <th>Val</th> <tmpl_loop val> <td><tmpl_var val></td> </tmpl_loop> </tr> <table> </tmpl_loop>

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Nesting <TMPL_LOOP> in HTML::Template by jeffa
in thread Nesting <TMPL_LOOP> in HTML::Template by rattusillegitimus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.