I was thinking on how one might silence that warning but NOT the warning if used in numeric comparisons (i.e. undef != $x), but couldn't think of an easy way since as the same warning message is used when concatenating string values.
I find the warning more useful in the case of trying to combine undef with a string, which people see most often when using print/printf to print a value that isn't defined. Without that warning, one wouldn't know the difference between a print w/undef vs. a print w/an empty string ('' or ""). Also, that usage can be trapped and compensated for in 1 place (the print routine -- that was the original motivation of the P module -- a safe way to print things without warnings, which usually are often set to terminate programs under the motto of "die early, die loudly (informatively)".
Under the current methodology, one has to use 2 checks to protect against that warning -- and it seems like that's one check too many for what, in my code, is a common case. That said, though, I realize there is a wide variety of coding idioms, and my find it hard to see such a question "objectively" -- so I thought I'd ask on here. How do you find those warnings use? I.e. what would be the compatibility issue with not issuing warnings in those circumstances?
Is that warning beneficial?
Note -- am talking about use of 'undef' with 'eq' and 'ne'. It's already the case that using 'undef' with 'or', 'and' and 'not' allow an operand to be 'undef' without accompanying warning messages.
How do people find the warning useful for 'eq'/'ne'?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |