i.e.
string1 or string2 = true if one of them has length>0
etc...
but it doesn't warn you about undef.
It sounds like you were thinking concatenation... mixing strings w/strings... but if you are comparing, aren't you already testing the value? i.e.:
> perl -we 'use strict;use P; P ((undef and 1) ? "yes": "");' no > perl -we 'use strict;use P; P ((undef or "") ? "yes": "no");' no > perl -we 'use strict;use P; P ((undef xor "") ? "yes": "no");' no > perl -we 'use strict;use P; P ((undef eq "") ? "yes": "no");' Use of uninitialized value in string eq at -e line 1. yes perl -we 'use strict;use P; P ((undef and 1) ? "yes": "no");' no > perl -we 'use strict;use P; P ((undef and 1) ? "yes": "no");' no > perl -we 'use strict;use P; P ((2 or undef ) ? "yes": "no");' y +es > perl -we 'use strict;use P; P ((2 xor undef ) ? "yes": "no");' yes perl -we 'use strict;use P; P ((2 ne undef ) ? "yes": "no");' Use of uninitialized value in string ne at -e line 1. yes Ishtar:/tmp> perl -we 'use strict;use P; P ((undef xor undef ) ? "yes" +: "no");' no perl -we 'use strict;use P; P ((not undef xor not undef ) ? "yes": "n +o");' no etc....
So you already have the ability to use defined/undefined as boolean states, why do you think a warning when using it with equality, (eq or ne), is useful?
Note I'm not talking about undef==3, or 2>=undef... or even undef cmp undef... as all of those *expect* some type of ordering or value.
But if something is eq or ne, doesn't.
Limiting it to that and considering we are only asking if what is in "$a" is the same as what's in "$b" (or not the same)...
You still think the warning for that specific case is more useful than not?
In reply to Re^2: Do people find warning for undef with string compare useful?
by perl-diddler
in thread Do people find warning for undef with string compare useful?
by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |