Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Answer: How to deal with undefined returned variables.

by davorg (Chancellor)
on Jan 19, 2001 at 21:54 UTC ( #53045=categorized answer: print w/replies, xml ) Need Help??

Q&A > subroutines > How to deal with undefined returned variables. - Answer 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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2016-10-26 20:52 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (347 votes). Check out past polls.