foreach $key (sort keys %tophash) { foreach $subkey (sort keys %{$tophash{$key}}) { print "$key/$subkey = $tophash{$key}{$subkey}\n"; } }