in reply to Warning for checking with undef
undef needs to be parsed as a function call in this context, so when used in the context of a relational expression, it needs round brackets after it to prevent it from being treated as a bareword. i.e.
if ( $foo == undef() )
would work just as well as
unless( defined($foo) )
whereas
if ( $foo == undef )
fails to satisfy for the same reason as
if ( $foo == DoesntMatterIfIamADefinedFunctionOrNot )
The same programming error is often made with shift();
One world, one people
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Warning for checking with undef
by Fletch (Bishop) on Jul 07, 2005 at 14:20 UTC | |
by anonymized user 468275 (Curate) on Jul 07, 2005 at 15:00 UTC | |
by Fletch (Bishop) on Jul 07, 2005 at 15:05 UTC | |
|