I usually accumulate info in a fetchrow while loop, it is easier for me conceptually to work with the data row by row:
... $sth->execute; my (%rows,%cols,$rtime,$dev,$value); while (($rtime,$dev,$value)=$sth->fetchrow) { $rows{$rtime}{$dev}=$value; $cols{$dev}++; } $sth->finish if $sth->{Active}; # really don't need finish if you got + all the data # now column headers can be computed my @cols=sort keys %cols; map { $cols{$cols[$_]}=$_+1 } 0..$#cols; # get indexes my @headers=('RTIME',sort keys %cols); my @row; print join("\t",@headers),"\n"; # and rows can be extracted (empty cells where a dev wasn't seen for a + particular rtime) for $rtime (sort keys %rows) { $row[0]=$rtime; map { $row[$cols{$_}]=$rows{$rtime}{$_} } keys %{$rows{$rtime}}; print join("\t",@row),"\n"; }
You would need to plug the data into HTML::Template, that I'm not as familiar with but it doesn't look hard.

HTH,
SSF


In reply to Re: Creating list of hashes within a list of hashes (DBI and HTML::Template) by sflitman
in thread Creating list of hashes within a list of hashes (DBI and HTML::Template) by 1Nf3

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.