http://www.perlmonks.org?node_id=475810


in reply to Top five words by occurrence

To select only words you can use \W+ (see perlre non-words):

... my @words = split /\W+/; ...

For show only first 5 occurs you can use this syntax:

foreach $w ( ( sort { $count{$b} <=> $count{$a} } keys %count ) [0..4] ) { ... }
.............

--
Marco Antonio
Rio-PM

Replies are listed 'Best First'.
Re^2: Top five words by occurrence
by ikegami (Pope) on Jul 18, 2005 at 16:56 UTC
    Using \W is not a good suggestion at all. "a1" and "123" would be considered words, but not "isn't".