It looks like you want to use an anonymous hash:
use strict;
use warnings;
my %hash = (
'key 1' => {
'innerhash1 key 1' => 'some data',
'innerhash1 key 2' => 'some more data',
},
'key 2' => {
'innerhash2 key 1' => 'even more data',
'innerhash2 key 2' => 'a bit more data',
},
);
foreach my $key (keys %hash) {
foreach my $inner_key ( keys %{$hash{$key}} ) {
print "$inner_key $hash{$key}->{$inner_key}\n";
}
}
$hash{'key 1'} contains a reference to the inner hash, but the inner hash itself is no longer named. You could rework the rest of your code to put data directly into there, and not have to worry about overwriting the data you've put in another inner hash.
If you want to seek more wisdom on your own, search for 'hash of hashes' or HoH if you're on a Perl site (like this one).