use strict;
use warnings;
use HTML::Template;
my $template = <<'TEMPLATE';
| Job |
Status |
Start |
End |
Remark |
|
TEMPLATE
my @x;
my @y;
while(){
if(/^AA/){
push @x, {row => [map {{a => $_}} split ',']};
}elsif(/^BB/){
push @y, {row => [map {{a => $_}} split ',']};
}
}
writeReport (\@x, "AA") if @x;
writeReport (\@y, "BB") if @y;
sub writeReport {
my ($cat, $name) = @_;
my $t = HTML::Template->new (scalarref => \$template);
$t->param (rows => $cat);
print $t->output();
}
__DATA__
AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33,
AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33,
BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33,
BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33,
BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33,
BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33,
AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33,
BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33,