The /g modifier tells the regex to search for more matches if possible, and for each match the while loop's code block is executed ( $count++ in this case ). So this oneliner will tell you how many times it saw a 'seek' in a file.perl -ne '$count++ while /seek/ig; print $count,"\n" if eof;' file.txt
In reply to Re: Counting words..
by mulander
in thread Counting words..
by No-Lifer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |