# time = O(N) memory = O(1) my $count = 0; while (my ($k, $v) = each(%h)) { $count += @$v; }