for (keys %temp) { my $tot; $tot += $_ for @{ $temp{$_} }; print "Average for state '$_': ", $tot/@{ $temp{$_} }, "\n"; }