defined($var)==0
Use of uninitialized value in numeric eq (==)
use strict;
use warnings;
my $variable = undef;
if( undef == 0 ){
print "undef == 0\n";
}
if( $variable == 0 ){
print "\$variable undef == 0\n";
}
if( "" == 0 ){
print "\"\" == 0\n";
}
if( undef eq 0 ){
print "undef eq 0\n";
}
if( undef eq 0 ){
print "\$variable undef eq 0\n";
}
if( undef eq "" ){
print "undef == \"\" \n";
}
if( 0 == "0" ){
print "0 == \"0\"\n";
}
if( 0 eq "" ){
print "0 eq \"\"";
}
if( undef eq "" ){
print "undef == \"\"\n";
}
if( defined ($variable) eq "" ){
print "undef == \"\"\n";
}
exit 0;
The last two cases may be of particular interest. undef is uninitialized as itself or from a variable, but as the result of defined it is not uninitialized. Magic conditions. I'm running Perl 5.26.1
Nvm: doy. Defined returns "" on undef.