Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Find most frequently used word in text file.

by NetWallah (Abbot)
on Dec 19, 2013 at 19:30 UTC ( #1067869=note: print w/ replies, xml ) Need Help??


in reply to Find most frequently used word in text file.

Try this alternative code, and let us know if you need help understanding it. Please indicate exactly what part you need help with :

perl -anE "for (@F){s/\W//g;$_ or next; $h{$_}++}}{$k=(sort {$h{$a} <= +> $h{$b}} keys %h)[-1]; say qq|The most frequent word in $ARGV is $k, + which was seen $h{$k} times.|" **YOUR-FILE-NAME**
(Use single quotes, if run on linux).

             When in doubt, mumble; when in trouble, delegate; when in charge, ponder. -- James H. Boren


Comment on Re: Find most frequently used word in text file.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-03-29 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:









    Results (630 votes), past polls