in reply to multiple regex logical AND

As previously noted, /^JRECOV="yes"/ && /^TEOJ="-w"/ is no good.

The desired condition is "Were JRECOV and TEOJ seen in the file?" Notice the past tense. The "and" needs to be done at the end of the file.

while (<>) { if ($seen) { $seen = 1; print "$ARGV: "; } $JRECOV = 1 if /^JRECOV="yes"/; $TEOJ = 1 if /^TEOJ="-w"/; if (eof) { # Not eof()! print $JRECOV && $TEOJ ? "yes" : "no", "\n"; $seen = 0; $JRECOV = 0; $TEOJ = 0; } }

Replies are listed 'Best First'.
Re^2: multiple regex logical AND
by bigswifty00000 (Beadle) on Dec 13, 2006 at 17:03 UTC

    thanks very much for your time and effort.

    I was trying to keep this to a line since this comes up all the time for me where I'd like to do a "grep like" search.

    I still may end up using your suggestion, if it can't be done in a one-liner.

    BigSwifty00000

      You needed far more basic help, so I went for readability.

      I'm sure it can be golfed to fit into a respectable (although lengthy) one liner, but I left that as an exercise for the reader.