Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Default subroutine parameters

by thelenm (Vicar)
on Apr 22, 2002 at 16:35 UTC ( #161091=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub mysub {
      my $foo = shift || 'default';
      # do stuff
    }
    
  2. or download this
    sub mysub {
      my $foo = shift; $foo = 'default' unless defined $foo;
      # do stuff
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://161091]
Approved by Albannach
Front-paged by giulienk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2015-03-28 00:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:









    Results (621 votes), past polls