my @word = ( (sort { $count{$b} <=> $count{$a} } keys %count) [0..4] ); my @count_word = map{ $count{$_} || 0 } @word;