http://www.perlmonks.org?node_id=777632


in reply to Parsing/regex question

What do you want the script to do when it encounters a "has rolled into" line? eg: skip the line and the following line or two?

You could set a variable used to keep state when a line matches and at the top of the loop skip lines if the variable is set. Here is some sample completely un-tested code:
my $lines_to_skip = 0; LINE: while (<MSOUT>) { if (0 < $lines_to_skip) { $lines_to_skip --; next LINE; } ... if ($line =~ /^(Position|Spot|Mark) has rolled into$/)) { $lines_to_skip = 1; next LINE; } }