my $numSubKeys = 0; foreach ( keys %hash ) { $numSubKeys += scalar keys %{$hash{$_}} }; }