in reply to Matching over two lines

Three problems:

Fix:

my $orderfound = 0; while (my $line = <>) { if ($line =~ /MSG-HDR/) { $orderfound = 1; next; } if ($orderfound && $line =~ /\|UB/) { print "$line\n"; } $orderfound = 0; }

Replies are listed 'Best First'.
Re^2: Matching over two lines
by TrekNoid (Pilgrim) on Mar 30, 2006 at 17:34 UTC
    Escaping the pipe did the trick

    The reason I'm clearing $orderfound where I am is because the UB line could be 1 or more lines later than the MSG-HDR line, so I don't want $orderfound to clear until I've matched that line.

    Thanks much...