Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Reading file and matching lines

by GotToBTru (Chaplain)
on Feb 11, 2014 at 14:23 UTC ( #1074423=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Reading file and matching lines
in thread Reading file and matching lines

use strict; use warnings; my $infile = shift; my $found_E = 0; my $sets = 0; open my $ifh, '<', $infile; while(<$ifh>) { if (/^E/) { $found_E = 1; next; } if ($found_E) { if (/^G/) { $sets += 1; $found_E = 0; next; } if (/^h/) { print "Error! Found h before G\n"; exit; } } } close($ifh); printf "Found %d sets from E to G uninterrupted by h\n",$sets;


Comment on Re^3: Reading file and matching lines
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2014-09-22 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls