Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 romping around the Monastery: (9)
As of 2014-08-22 04:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (146 votes), past polls