Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Counting occurances of a pattern in a file

by gnat (Beadle)
on Aug 31, 2000 at 02:54 UTC ( [id://30441]=note: print w/replies, xml ) Need Help??


in reply to Counting occurances of a pattern in a file

There are a lot of problems. You read multiple lines from the file, you close() inside the while() loop, .... Here's what you want:
while (<INPUT>) { $n++ if /^Algorithm/; last if /^Experiment Name/; } close INPUT;
Cheers;

Nat

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-24 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found