in reply to help formatting output of particular loop

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