Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Preferred technique for named subroutine parameters?

by Anonymous Monk
on May 22, 2009 at 18:58 UTC ( [id://765727]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # new MyModule({arg1 => 'val1', arg2 => 'val2'})
    sub new {
    ...
        croak('oh crap!') if ref($_[0]) != 'HASH'
        my %args = %{$_[0]};
    }
    
  2. or download this
    # new MyModule(arg1 => 'val1', arg2 => 'val2')
    sub new {
    ...
        croak('oh crap!') if @_ % 2;
        my %args = @_;
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 05:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found