Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Answer: How to deal with undefined returned variables.

( #53045=categorized answer: print w/ replies, xml ) Need Help??

Q&A > subroutines > How to deal with undefined returned variables. contributed by davorg

If zero or the empty string aren't valid values then you could use:

$CONFIG{HASHTYPE} = $cfg->val("MISC","HASHTYPE") || 'sha1';

Otherwise, you'd need:

$CONFIG{HASHTYPE} = defined $cfg->val("MISC","HASHTYPE") ? $cfg->val("MISC","HASHTYPE") : 'sha1';

which isn't much different to what you've got.

Comment on Answer: How to deal with undefined returned variables.
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2015-07-06 06:13 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 (70 votes), past polls