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

bigswifty00000 has asked for the wisdom of the Perl Monks concerning the following question:

multiple regex logical AND

Hey All!

I am trying to check a config file for the existence and settings of two parameters.

I believe it requires a logical AND.

I realize that this is checking for an AND on the same line,

perl -nle 'print $ARGV if !$seen{$ARGV}++ ;print if /^JRECOV="yes"/|/^TEOJ=-w"/' *

ALSO printing the filename only if BOTH conditions are met.

I can't seem to find the regex that will work for this, any help would be greatly appreciated.

Thanks!

BigSwifty00000

Sorry, I realized my LAST test was with an OR, after I posted.

Carry on!

BigSwifty0000

I corrected the missing " and tried this (this file has the 2 params set to what I'm searching for)

perl -nle 'print $ARGV if !$seen{$ARGV}++ ;print if /^JRECOV="yes"/&&/^TEOJ="-w"/' ss1lab02

AND

perl -n00 -le 'print $ARGV if !$seen{$ARGV}++ ;print if /^JRECOV="yes"/ms &&/^TEOJ="-w"/ms' ss1lab02

Neither is returning the lines (filename is returned)