my $top_X = 10; foreach $key (sort { $hash{$a} <=> $hash{$b} } keys %hash) { print "$key\t\t= $hash{$key}\n"; last if --$top_X <= 0; }