As a little workout for my newly acquired CGI muscles I put together:

use strict; use warnings; use CGI::Pretty; my %data; while (<DATA>) { chomp; my ($code, $date, $time) = split /\s+/; next if ! defined $time; push @{$data{$date}}, [$code, $time]; } my $cgi = CGI->new(); my $tableContents; for (sort keys %data) { $tableContents .= $cgi->Tr ($cgi->td ('&nbsp;')); $tableContents .= $cgi->Tr ($cgi->td ($_)); for (sort {$a->[1] cmp $b->[1]} @{$data{$_}}) { $tableContents .= $cgi->Tr ( $cgi->td ($_->[0]), $cgi->td ($_->[1]) ); }; } #print $cgi->header (); print $cgi->start_html (); print $cgi->table ($tableContents); print $cgi->end_html (); __DATA__ CA642997 2007-01-29 03:05:00 CA651167 2007-01-29 03:05:00 CA651038 2007-01-29 19:00:00 CA650995 2007-01-30 19:00:00 CA652568 2007-01-31 01:05:00 CA652880 2007-01-31 01:30:00 CA652884 2007-01-31 06:00:00 CA643602 2007-02-01 00:30:00 CA652881 2007-02-01 01:00:00

which prints output that renders as (having stripped off headers and stuff for posting here):

 
2007-01-29
CA642997 03:05:00
CA651167 03:05:00
CA651038 19:00:00
 
2007-01-30
CA650995 19:00:00
 
2007-01-31
CA652568 01:05:00
CA652880 01:30:00
CA652884 06:00:00
 
2007-02-01
CA643602 00:30:00
CA652881 01:00:00

DWIM is Perl's answer to Gödel

In reply to Re: help formatting output of particular loop by GrandFather
in thread help formatting output of particular loop by eisdrache

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.