Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Re: Annoying warnings...
in thread Annoying warnings...

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:

# I want a reference whose type is 'HASH' ref $x && reftype $x eq 'HASH';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://475456]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-19 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found