in reply to find the number of words that a user has chosen for an input file that a user has also chosen

You don't need a script for that. You can get your count on the command line:

$ cat 1176022.txt The foo bar all of the foo's men Not here Foo foo foo Notfoo What the foo Expecting five foos $
$ perl -nE '$l++; $i += () = $_ =~ /\bfoo\b/g; say "After line $l: $i" +' 1176022.txt After line 1: 1 After line 2: 2 After line 3: 2 After line 4: 4 After line 5: 4 After line 6: 5 After line 7: 5 $

See perlrun for Perl's command line switches.


The way forward always starts with a minimal test.
  • Comment on Re: find the number of words that a user has chosen for an input file that a user has also chosen
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: find the number of words that a user has chosen for an input file that a user has also chosen
by distro (Initiate) on Nov 16, 2016 at 22:31 UTC
    I know, but I want a program for easy repetition and access whenever.