in reply to "defined" function fails to evaluate expression; feature or fault?

While I've previously been able to do it like this: if (defined ($var1 && $var2))

Hi,

That expression does not check of $var1 and $var2 are defined, it checks if the result of  $var1 && $var2 is defined

The result of && is always defined even if both $var1 and $var2 are undefined

&& tests for truth, and the result is always defined

definedness is not truth

$var1 || $var2 also tests for truth, but the result is the value of $var1 or the value of $var2 , the result can be undef

the empty string is false, its not true, its not undef

On truthiness

  • Comment on Re: "defined" function fails to evaluate expression; feature or fault? (truth)
  • Download Code