Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Default Hash Key

by wade (Pilgrim)
on May 02, 2008 at 00:32 UTC ( [id://684060]=note: print w/replies, xml ) Need Help??


in reply to Default Hash Key

You could always do something like:
my $foo = exists($description{$input}) ? $description{$input} : "default value";
Or the two-step approach:
my $foo = $description{$input}; $foo = "default value" if (!defined($foo));
--
Wade

Replies are listed 'Best First'.
Re^2: Default Hash Key
by Anonymous Monk on Mar 13, 2012 at 13:44 UTC

    Using the "//" operator, this folds into:

    my $foo = $description{$input} // "default value";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2026-02-14 05:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.