Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Dereferencing %hash that does not exist.

by choroba (Canon)
on Sep 04, 2013 at 10:28 UTC ( #1052282=note: print w/ replies, xml ) Need Help??


in reply to Dereferencing %hash that does not exist.

In recent Perl (which 5.10.1 is in this context), you can also use the defined-or operator:

my $revmod = %{ $_[0] // {} };

Update: It should work with plain ||, too, in the older versions. Just make sure you never call it with 0 as the argument.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Dereferencing %hash that does not exist.
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2015-07-30 18:16 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 (273 votes), past polls