Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: RFC: Defined-Or for before Perl 5.10 (def(...))

by tye (Cardinal)
on Oct 29, 2010 at 19:12 UTC ( #868386=note: print w/ replies, xml ) Need Help??


in reply to RFC: Defined-Or for before Perl 5.10

See def -- Deal nicely with undefined values that I posted in 2000. But I'd actually do it differently:

sub def { my $var= \$_[0]; my $val; while( @_ && ! defined $val ) { $val= shift @_; } $$var= $val if ! defined wantarray; return $val; } # For example: my $size= def( $ENV{MAXSIZE}, -s $swapFile, -1 ); # Or void context causes $size to be modified def( my $size, $ENV{MAXSIZE}, -1 );

- tye        


Comment on Re: RFC: Defined-Or for before Perl 5.10 (def(...))
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2014-08-31 04:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls