#!perl use strict; use warnings; my %hash = ( "A" => 1, "B" => 1, "C" => 1, "D" => 1, "E" => 1, "B" => 1, "F" => 1, "G" => 1, "H" => 1, "I" => 1, "J" => 1, ); for my $key (sort(keys(%hash))) { print "$key\n"; } print "_"x10,"\n"; my %hash2 = makesubhash(); for my $key (sort(keys(%hash2))) { print "$key\n"; } sub makesubhash { my %subhash = ( "A" => 1, "B" => 1, "C" => 1, "D" => 1, "E" => 1, "B" => 1, "F" => 1, "G" => 1, "H" => 1, "I" => 1, "J" => 1, ); } #### A B C D E F G H I J __________ B C D E F G H I #### A B C D E F G H I J __________ A B C D E F G H I J