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)
In reply to Re: How to print the lines immediately above and below a matching line?
by space_monk
in thread How to print the lines immediately above and below a matching line?
by Bio90
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |