This problem is tailor-made for the flipflop operator.
perl -i.bak -nwe'(/REx/ .. 0) && print'
Of course, that will print the line that matched the REx. What you really want is hard to tell -- whether you want to start with the line after the REx or whether you want the line with the REx on it, and just starting as soon as the end of the REx matches.
perl -i.bak -nwe'(s/.*REx// .. 0) && print'
That will provide option #2 -- you get everything directly following the REx match, including the text on the same line.
perl -i.bak -nwe'print if $match; /REx/ && $match++'
And this one gives you all of the lines immediately following the line where the REx matched.
All of these examples can also be wrapped in while (<>) { ... } instead of used with the command line switches if necessary.
-dlc
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.