Yes it evaluates to true, because undef is zero numerically regardless of where it came from. It also triggers warnings from each side when the undefined value is coerced into a number, which is exactly what the OP was seeing.
freebie:~ 755> cat quux use warnings; my $foo = undef; if( $foo == undef ) { print "true\n" } freebie:~ 756> perl quux Use of uninitialized value in numeric eq (==) at quux line 3. Use of uninitialized value in numeric eq (==) at quux line 3. + true
Update: Added something that runs inside the conditional to show that it's not being interpreted as a bareword, both sides trigger the undef-used-as-a-number warning, and that the conditional is true without parens.
--
We're looking for people in ATL
In reply to Re^4: Warning for checking with undef
by Fletch
in thread Warning for checking with undef
by icg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |