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 line 3 - line 4 target - line 5 hold this line - line 6 Hold this line
\ 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

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -