Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Do you see the very-obvious bug in the code? Obviously you do. Sorry, but I don't. Could you explain or demonstrate the bug with an SSCCE? There is only one point in time when $count will be exactly equal to 2, and anyone could spot the flaw immediately. That seems to be the OP's specification, "extract only the second block of lines that meet the pattern" (emphasis mine). Note how the OP's sample input data explicitly says "lines not to be extracted". I've added an extra block to the input for testing:
Outputs:
... which seems to me to meet the specification. Cristoforo's code also works as posted, except that it does not output the START and END markers. Whereas your code, once I fix all the syntax errors and change "do something with the line" to a print, outputs for the same sample input:
Update: Added the last two paragraphs, and minor edits for clarity. In reply to Re^2: [Solved]Need to extract a particular block of lines between two patterns
by haukex
|
|