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