http://www.perlmonks.org?node_id=703717


in reply to Retrieving data from multidimensional hashes

A couple of options, depending on what appeals to you:
my $num = keys %{ $hash{key} }; # or my $ref = $hash{key}; my $num = keys %$ref;
The first one is short-hand for accessing the second-level hash directly, though I find it a tad ugly, especially if the structures get deeper than two levels. The second one grabs the reference for the second level hash and then calls keys on that, which is a bit more explicit.