in reply to Re: regex help ...
in thread regex help ...

Pardon me if I say ick! Every time I see "flag variables" I cringe. That could be written better (IMHO) like so: perl -ne 'next unless /loop/../endloop/; print if /warn/;' file.txt

Replies are listed 'Best First'.
Re:^3 regex help ...
by Roy Johnson (Monsignor) on Nov 25, 2003 at 15:49 UTC
    or just
    perl -ne 'print if /loop/../endloop/ and /warn/' file.txt

    The PerlMonk tr/// Advocate
Re: regex help ...
by delirium (Chaplain) on Nov 25, 2003 at 18:13 UTC
    Nice.

    From perlop:

    Each ".." operator maintains its own boolean state. It is false as long as its left operand is false. Once the left operand is true, the range operator stays true until the right operand is true, AFTER which the range operator becomes false again.

    I had no idea about this before I saw your post. That will clean up many of my scripts quite a bit. Thanks for pointing that out.