in reply to Hash of Hashes: Get the next Key without foreach loop

You're going to run into problems with the second block of code you posted.

You treat $hash{$key1}{$key2} as having a scalar, string value (for use as a hash key):

my $key3 = $hash{$key1}{$key2};

Then in the next line you treat the same value as a hash reference:

my $value = $hash{$key1}{$key2}{$key3};

You are effectively working on two different data structures:

%hash = ( key1 => { key2 => $some_key } ); %hash = ( key1 => { key2 => { $some_key => $some_value } } );

-- Ken