It is often annoying, though in some cases is does help find bugs.
I don't like introducing "if defined" checks, as they blow up the code size and make it less readable. Luckily the // operator provides a slightly more concise solution that can be use in many (but not all!) situations where you want to do string-comparison on a variable that may be undef:
Instead of...
if ($possibly_undef eq 'Hello') { ...
...write:
if ($possibly_undef//'' eq 'Hello') { ...
Or of course "no warnings 'uninitialized';" if you want to disable it completely, but I don't usually do this.
In reply to Re: Do people find warning for undef with string compare useful?
by smls
in thread Do people find warning for undef with string compare useful?
by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |