Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: find a string and count of its occurence in a text file

by dwu (Monk)
on Nov 14, 2007 at 05:53 UTC ( [id://650686]=note: print w/replies, xml ) Need Help??


in reply to Re: find a string and count of its occurence in a text file
in thread find a string and count of its occurence in a text file

And to chuck in an (incredibly primitive) idea for a line count as well:
_data.txt_ abc:AB CD:100 def:DE FG:101 ghi:GH IJ:102 abc:AB CD:100 ghi:GH IJ:103 my $count; while ( <FILE> ) { print if /^abc:/; $count++ if /^abc/; } print "Matched $count times\n"; _output_ abc:AB CD:100 abc:AB CD:100 Matched 2 times
Update: I'm silly; added condition for incrementing $count.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-26 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found