for my $key (sort keys %hash) { print "KEY: $key \n"; for my $subkey (sort keys %{$hash{$key}} ) { print "nested key: $subkey => $hash{$key}{$subkey} \n"; } print "-------\n"; }