Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by tye (Sage)
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        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://868386]
help
Chatterbox?
[karlgoethebier]: Ouch! How can i link to a section in my profile?

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-06-24 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (557 votes). Check out past polls.