in reply to Re: complaint: always testing defined()
in thread complaint: always testing defined()

But please note that you can't use this to compare to '0', or any other value that evaluates to false in a boolean context, so you should only use it to compare it with constants.

perl -wle 'if( ("0" || "") eq "0"){print "yes"} else { print "no" }' no

Replies are listed 'Best First'.
Re^3: complaint: always testing defined()
by parv (Parson) on Nov 02, 2007 at 13:42 UTC

    It seems // (binary defined-or operator) isn't popular enough for some reason (available at least in 5.8.8) ...

    my $p; $p //= 2; my $q = 0; $q //= 2; print $p , $q; # 20

    A few minutes later... Well, above isn't available by default in 5.8.8 but via separate patch. It seems the patch isn't popular enough for some reason.

    :)

        Thanks for the clue. I did not realize that the defined-or patch is unconditionally applied these days to Perl 5.8.8 port (as in FreeBSD lang/perl5.8 port).