|
|
| Perl: the Markov chain saw | |
| PerlMonks |
Re: How to print the lines immediately above and below a matching line?by space_monk (Hermit) |
| on Nov 25, 2012 at 16:29 UTC ( #1005504=note: print w/ replies, xml ) | Need Help?? |
|
TMTOWTDI answer. :-) Instead of reading the file line by line as suggested in other answers above, you could also read the entire file into a scalar and use a multi line regexp to do it. Look up use of the /m option on regexp matching. Any Monk who wishes to extend this thread with a complete answer using this method is more than welcome to do so (I'm a bit short of time)
A Monk aims to give answers to those who have none, and to learn from those who know more.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||