Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Counting words..

by mulander (Monk)
on Oct 24, 2005 at 15:08 UTC ( [id://502483]=note: print w/replies, xml ) Need Help??


in reply to Counting words..

Here is one way to do it:
perl -ne '$count++ while /seek/ig; print $count,"\n" if eof;' file.txt
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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-18 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found