foreach my $key ( (sort {$hash{$b} <=> $hash{$a} } keys %hash )[0..9] ) { print $key, "\n"; }