How can I grab multiple lines after a matching line in Perl? -
I am parsing a large file ending with Pearl line-by-line (\ n), but when I'm certain Say the keyword, "target", I have to catch all the rows between the target and the next completely empty line.
Therefore, a section of the file has been given:
line 1
\ n
It should be: Line 2 - Line 5 Hold this line - Line 6 Hold this line
Reason I'm having trouble, I'm already going through a file-line-by-line; How can I differentiate through the parsing process?
You want something like this:
my @ ring; While (& lt; FILE & gt;) {if (/ TARGET /) {Push @ impaired, $ _; While (& lt; FILE & gt;) {Final if / ^ $ /; Push @ bread, $ _; }}}
Comments
Post a Comment