in reply to if not defined

Your problem is in operator precedence. After adding parenthesis to match precedence, you have:

not ( ( ( ( ( defined($pname) && $pname ne '' ) && defined($policy_ur) ) && $policy_ur ne '' ) && not defined($odate) ) && $odate ne '' )

I think you want to use the higher precedence logical not operator (!). That way your condition will work out to this:

( ( ( ( (!defined($pname) && $pname ne '') && defined($policy_ur) ) && $policy_ur ne '' ) && not defined($odate) ) && $odate ne '' )


TGI says moo

Replies are listed 'Best First'.
Re^2: if not defined
by pKai (Priest) on Mar 23, 2007 at 19:11 UTC
    I'd say the former (resembeling the OP) makes sense:

    It's testing for all vars at first if it is defined and then if it also isn't the empty string. This partial results is inverted for $odate and then chained on the same level. The result of that is inverted by the leading "not".

    If you ignore the (possible) warnings, when a string function is applied to undef

    !(length($pname) && length($policy_ur) && !length($odate))
    will yield the same.

    That may be what he wants or not.

    Your (!defined($pname) && $pname ne '') on the other hand is only true für $pname being "undef", so contains a redundant test.