in reply to sum function

sub _sum { my $hash = shift; my $total = 0; $total += $_ for @$hash{ @_ }; return $total; }
You can use a list of keys as indices into a hash. It's called a hash slice, and it's very very nice.