Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Getting lines in a file between two patterns

by hippo (Bishop)
on Jun 27, 2016 at 08:28 UTC ( [id://1166635]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Getting lines in a file between two patterns
in thread Getting lines in a file between two patterns

I am unable to reproduce your findings. Here are the results with perl 5.20.3:

$ cat 980408.pl #!/usr/bin/perl -w use strict; while (<DATA>) { process_record() if /^START/; } sub process_record { my $line; while ($line = <DATA>, $line !~ /^END/) { print "$line" } print "\n"; #a printout spacer for next record } __DATA__ XXXX YYYY START These are the first set of lines which are to be extracted END START New line And new Will be extracted? END XXX ZZZ YYY START These are the second set of lines which are to be extracted END aasds tteret tertetr $ ./980408.pl These are the first set of lines which are to be extracted New line And new Will be extracted? These are the second set of lines which are to be extracted $

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-19 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found