in reply to Re^7: Regex result being defined when it shouldn't be(?)
in thread Regex result being defined when it shouldn't be(?)
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.1use 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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Regex result being defined when it shouldn't be(?)
by soonix (Chancellor) on Nov 18, 2017 at 11:32 UTC |