you still don't know what perl is able to do ;)
i post you code the last time because this is slowly getting VERY weird. you surely are able to make it cleaner.
add this method to the script:
############################################################
sub print_total_by_state {
############################################################
my ($data_ref) = @_;
my %cache;
my $total = 0;
foreach (values %$data_ref) {
foreach my $state (keys %$_) {
$cache{$state} += $_->{$state};
$total += $_->{$state};
}
}
print "<tr>\n";
print "\t<td>Total by State</td>\n";
foreach my $state (keys %cache) {
print "\t<td>", $cache{$state}, "</td>\n";
}
print "\t<td>$total</td>\n";
print "</tr>\n";
}
call the subroutine between the table definitions.
|