No offense, but i'd rather just learn a mini-language like Template:
package Simple::Class; use strict; use warnings; use Class::MethodMaker new_hash_init => 'new', get_set => [qw(age name weight)], ; sub load_data { return [ map { Simple::Class->new({ name => $_, age => int(rand(50))+20, weight => int(rand(150))+20, }) } qw(bob bill brian babette bobo bix) ]; } package main; use strict; use warnings; use Data::Dumper; use Template; my $template = Template->new; $template->process(\*DATA,{people => Simple::Class::load_data}) || die $template->error; __DATA__ [% colors = ['white','gray'] %] <table> <tr><th>name</th><th>age</th><th>weight</th></tr> [% FOREACH person = people %] [% PROCESS row person = person %] [% END %] </table> [% BLOCK row %] [% color = colors.shift %] <tr> <td bgcolor="[% color %]">[% person.name %]</td> <td bgcolor="[% color %]">[% person.age %]</td> <td bgcolor="[% color %]">[% person.weight %]</td> </tr> [% colors.push(color) %] [% END %]
I will agree that i like your template better when it comes to alternating colors. I probably should have handled the color picking inside the Perl code and not the template, but this is a trivial move. As it stands, i am really starting to like the Template mini-language.

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 Re: HTATR II: HTML table generation via DWIM tree rewriting by jeffa
in thread HTATR II: HTML table generation via DWIM tree rewriting by princepawn

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.