in reply to Re: Parse a block of text
in thread Parse a block of text
This solution fails if there is a stop-line not balanced by a start-line. A better solution (or at least one that doesn't have a subtle potential bug) is:
<p Output: <puse warnings; use strict; my $START = qr{ \A Info [ ] I [ ] Want }xms; my $STOP = qr{ \A Start [ ] of [ ] Info [ ] I [ ] don't }xms; while (<DATA>) { # if (/$START/ .. /$STOP/ xor /$STOP/) { # print; # } if (/$START/ .. /$STOP/ and not /$STOP/) { print; } } __DATA__ asdfsdfds asdfasdf blah blah blah Info I Want I want this line And this line And this line this is the last line i want Start of Info I don't want blah blah blah blah blah Start of Info I don't want blah blah blah blah blah
Info I Want I want this line And this line And this line this is the last line i want
|
|---|