in reply to When warnings get in the way
You can turn on a certain kind of warning for a block or function, like
IMO, there is nothing wrong with disabling a warning, as long as you do it only to certain warnings, not all (like no warnings;), and only for the part of code where the warning is ok. This is especially important with warnings such as no warnings "exiting"; for which there is no such easy way to avoid.if (do { no warnings "uninitialized"; $foo eq "true" }) { ... }
In this case however, I see nothing wrong with the explicit $foo && test, I do not think it is really bad. For a more comprehensible code, I'd write something like
orif (defined($foo) && $foo eq "true") { ... }
or evenif (($foo || "") eq "true") { ... }
if ((defined($foo) ? $foo : "") eq "true") { ... }
|
---|