for my $i ( keys %dub_hash ) { my $key = "$i -- "; if (keys (%{$dub_hash{$i}}) > 1) { print $key, join( "\n" . ' ' x length $key, keys %{ $dub_hash{ $i } } ),"\n"; } }