############################################################ 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 "\n"; print "\tTotal by State\n"; foreach my $state (keys %cache) { print "\t", $cache{$state}, "\n"; } print "\t$total\n"; print "\n"; }