Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to count the total number of times the word 'the' and 'and' occur in 5 files i selected?

by Gilimanjaro (Hermit)
on Jan 28, 2003 at 21:25 UTC ( [id://230756]=note: print w/replies, xml ) Need Help??


in reply to How to count the total number of times the word 'the' and 'and' occur in 5 files i selected?

A probably slow but working solution:

while(<>) { # loop thru all file arguments' lines for (split) { # split line on default separator (' ') $occ{$_}++; # increment counter for each word } } print $occ{'and'}+$occ{'the'}; # add occurrences

I haven't actually checked if th

  • Comment on Re: How to count the total number of times the word 'the' and 'and' occur in 5 files i selected?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found