Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: An idiom for selecting true, false, or undef.

by xdg (Monsignor)
on Mar 17, 2009 at 16:43 UTC ( #751241=note: print w/ replies, xml ) Need Help??


in reply to An idiom for selecting true, false, or undef.

It may not be a good idiom, but usually I only check wantarray for a true value, and just return a scalar value in either scalar or void context and just let Perl throw it away if unused. I think that's probably reasonable for anything for which the typical case is to return one or more values and I don't see much point in adding the void case just to be pedantic.

For fork, the last time I did it, I used a three-part if/elsif/else for clarity.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.


Comment on Re: An idiom for selecting true, false, or undef.
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-12-22 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (110 votes), past polls