Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Omitted subroutine arguments

by mincus (Chaplain)
on Mar 16, 2011 at 18:12 UTC ( #893603=note: print w/replies, xml ) Need Help??


in reply to Omitted subroutine arguments

I do just about the same as the replies above, almost all of my subroutines look like
sub my_sub { my %args = ( param1 => 'default', param2 => 0, @_, ); ... }
Then I call it like
my_sub( param1 => 'Not Default Text' );
then the defaults get overridden with what I send, or use the defaults if I don't. If it is an object method, then I just add a line before the args:
sub my_sub { my $self = shift; my %args = ( @_, ); .... }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2021-09-23 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?