- or download this
# time = O(N) memory = O(N*M)
my $count = map @$_, values %h;
- or download this
# time = O(N) memory = O(N)
my $count = sum map { scalar @$_ } values %h;
- or download this
# time = O(N) memory = O(N)
my $count = 0;
$count += @$_ for values %h;
- or download this
# time = O(N) memory = O(1)
...
while (my ($k, $v) = each(%h)) {
$count += @$v;
}