in reply to Simulating a summary of a hash

I have the feeling I'm missing a deeper question that you may have, but here's untested code for the surface question:
sub somefunction { my ($href, $key) = @_; my %counts; $_->{$key} && ++$counts{$_->{$key}} for values %$href; return %counts; }