Now you realize, I mentioned only the "eq" and "ne" operators (cuz or/and/not already work on undef w/no warning).
I'm not talking concatenation, or where you print it out.
But specifically where you are testing the value against something else.
In that case, do you still think, that if you are doing a comparison on it, you wouldn't notice that "empty"(undef) is or is not equal to some other string?
How do you see it different than "and" "or" and "not"...

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.