foreach my $k (sort keys %hash) { for my $subkey ( sort keys %{ $hash{$k} } ){ print $k,":",$subkey,":",$hash{$k}->{$subkey},"\n"; } }