http://qs321.pair.com?node_id=606315


in reply to if not defined

For one, it's valid Perl syntax:
D:\Temp>perl -c -e "if (not defined($pname) && $pname ne '' && defined +($policy_ur) && $policy_ur ne '' && not defined($odate) && $odate ne +''){}" -e syntax OK
But it's probably not doing what you expect:
D:\Temp>perl -MO=Deparse,p -e "if (not defined($pname) && pname ne '' +&& defined($policy_ur) && $policy_ur ne '' && not defined($odate) && +$odate ne ''){}" if (not defined $pname && $pname ne '' && defined $policy_ur && $polic +y_ur ne '' && !(defined $odate && $odate ne '')) { (); } -e syntax OK
not has a much lower precedence than &&

use either not and and or ! and && in conjunction to get the intended effect.

Update: Seems like newly accuired syntax highlighting was distracting me ;-). Though a little bit complicated the assembly of the leading not (inverting the result of the whole test) with the && (chaining all the inner sub-tests together) makes sense.