Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Annoying warnings...

by adrianh (Chancellor)
on Jul 16, 2005 at 14:51 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2021-05-14 11:43 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (150 votes). Check out past polls.