|
Posted by A. Sinan Unur on January 25, 2008, 5:56 am
Please log in for more thread options
> Hi
use strict;
use warnings;
> Are these the same?
No.
> if ($x eq undef) {print "hi"}
> if (not defined $x) {print "hi}
Can't find string terminator '"' anywhere before EOF at C:\Temp\t.pl
line 2.
> If so, which is preferred?
Testing equality with undef will generate a warning regardless of the
value of $x.
unless ( defined $x )
or
if ( not defined $x )
would not. They would also convey the intended meaning better.
> Note: I have tried posting to perl beginners (the obvious choice for a
> simple question) but the posts do not appear.
You can ask all Perl related questions here. However, you should read
and follow the posting guidelines to get the best help.
Sinan
--
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>
|