Syntactic Confectionery Delight | |
PerlMonks |
Re^2: Annoying warnings...by adrianh (Chancellor) |
on Jul 16, 2005 at 14:51 UTC ( [id://475456]=note: print w/replies, xml ) | Need Help?? |
Ugg — that's ugly, and quite obfuscated: it isn't apparent from glancing at that code exactly what it does or that it's written like that to avoid a warning I disagree. That's a common idiomatic way of resolving the problem of false/undef in some expressions and I see it in lots of code. The only problem with this strategy is that it sometimes gets used in places where non-undef false values like '0' shouldn't be ignored, which can lead to odd bugs. Not a problem in this instance. $x && reftype $x eq 'HASH' As already pointed out this breaks for true non-reference values. In this particular instance I'd probably make it a bit more explicit the exact thing I'm looking for:
In Section
Seekers of Perl Wisdom
|
|