Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: disadvantages of perl

by JavaFan (Canon)
on Jul 02, 2009 at 15:22 UTC ( #776773=note: print w/ replies, xml ) Need Help??


in reply to Re: disadvantages of perl
in thread disadvantages of perl

if ( defined $r && ref $r && ref $r eq 'HASH' && keys %$r ) { ... }
There's no need to write it like that. 'ref' never returns an undefined variable. You may write this as:
if (ref($r || "") eq 'HASH' && keys %$r) { ... }
Or, after turning off the appropriate warning:
if (ref $r eq 'HASH' && keys %$r) { ... }
which isn't too bad.

Note that it won't enter the block if $r is a blessed hash, but that I consider a feature. (Otherwise, replace ref with Scalar::Util::reftype).


Comment on Re^2: disadvantages of perl
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2015-07-05 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls