Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Preferred technique for named subroutine parameters?

by spacebat (Beadle)
on May 26, 2009 at 22:36 UTC ( [id://766302]=note: print w/replies, xml ) Need Help??


in reply to Preferred technique for named subroutine parameters?

While I lean towards the flat list, I dislike more having to remember which convention is required in a particular piece of code. So I tend to support both forms:
sub new { my $class = shift; my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; # ... }
update: possibly bad example - that's how I retrofit some of the legacy code at work. New code would inherit new() from Moose or Mouse :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-23 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found