in reply to Re^2: get n lines before or after a pattern
in thread get n lines before or after a pattern

This is of interest, and excellent, too, JohnGG!

I was aware that I didn't confine the local $/; to a block, not thinking too much about the code snippet. However, I'll remember--as a best practice--to do so with future local (dynamically scoped) variables. It was good to point this out.

I like your refined/seasoned coding: scoping, reading in a multi-line record, opening a file handle on the record-containing scalar, and then grepping through the lines to display the OP's desired output.

Indeed, this is of interest, very well thought out, and very much appreciated.

Thank you.