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

Re: Regex and writing lines in file

by Corion (Patriarch)
on Apr 30, 2013 at 11:19 UTC ( [id://1031388]=note: print w/replies, xml ) Need Help??


in reply to Regex and writing lines in file

If your three lines are not in the string buffer you are matching against already, you cannot solve this with regular expressions. I would maintain a "skip" count to know how many lines to skip:

my $skip; while (<>) { next if $skip--; if( /mypattern/ ) { $skip= 3; } else { print "Have line '$_'"; }; };

If your three lines are in the string buffer already, a new line is defined by the newline character(s) appearing. So you would match three newline charachters with non-newline characters in between them to skip three lines forward.

Without seeing code, it's hard to advise better.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found