tmharish has asked for the wisdom of the Perl Monks concerning the following question:
I, accidentally stumbled on the fact that undef eq ''
( Leaving out strict and warnings is intentional )
perl -e 'if( undef eq "" ) { print "In\n" } else { print "Out\n" }' In perl -e 'my $tmp; if( $tmp eq "" ) { print "In\n" } else { print "Out\ +n" }' In perl -e 'my $tmp; if( $tmp ne "" ) { print "In\n" } else { print "Out\ +n" }' Out perl -e 'if( undef ne "" ) { print "In\n" } else { print "Out\n" }' Out
Is there some reasoning for this?
The problem with this is that when I want to clean up warnings I add $tmp and:
perl -e 'my $tmp; if( $tmp and ( $tmp eq "" ) ) { print "In\n" } else +{ print "Out\n" }' Out
The outcome is to throw the entire program off!
Back to
Seekers of Perl Wisdom