Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Top five words by occurrence

by mda2 (Hermit)
on Jul 18, 2005 at 16:50 UTC ( #475810=note: print w/replies, xml ) Need Help??


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".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://475810]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2019-12-11 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?