Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 browsing the Monastery: (5)
As of 2020-09-28 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (143 votes). Check out past polls.

    Notices?