my $top = 5; foreach $w (sort { $count{$b} <=> $count{$a} } keys %count) { last if $top--; print "$count{$w} $w\n"; }