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

snape has asked for the wisdom of the Perl Monks concerning the following question:

Suppose, I have a hash of hashes which has three keys. I would like to know is it possible to go to know next key without using foreach loop. for example: I don't want to do the following

foreach my $key1 ( sort keys %hash){ foreach my $key2 ( sort keys %{$hash{$key1}){ foreach my $key2 ( sort keys %{$hash{$key1}{$key2} ){ + } } }

I am interested to know if I have the knowledge of 2 keys and not the third ( and we don't have multiple third keys), is it possible to know the value for the hash of hashes. Something like: (more of a crude way of doing)

foreach my $key1 ( sort keys %hash){ foreach my $key2 ( sort keys %{$hash{$key1}){ my $key3 = $hash{$key1}{$key2}; my $value = $hash{$key1}{$key2}{$key3}; } }

Sorry for confusion. Thanks.