Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Preferred technique for named subroutine parameters? (PBP)

by toolic (Bishop)
on May 22, 2009 at 21:06 UTC ( [id://765752]=note: print w/replies, xml ) Need Help??


in reply to Preferred technique for named subroutine parameters?

For the record, the Perl Best Practices book (chapter 9, section titled "Named Arguments") recommends passing a hashref. The reason cited is the same as that given by AnomalousMonk in Re: Preferred technique for named subroutine parameters?. In fact, that sub-thread would make a great appendix to the PBP section!
  • Comment on Re: Preferred technique for named subroutine parameters? (PBP)

Replies are listed 'Best First'.
Re^2: Preferred technique for named subroutine parameters? (PBP)
by shmem (Chancellor) on May 23, 2009 at 10:16 UTC

    That is another point where I strongly disagree with 'Perl Best Practices'. Passing a hash reference as an argument to a sub is just that -: it is passing one argument to a subroutine which expects one argument - a hash reference, and not a list of parameters (named or not).

    In my book of 'Personal Best Practices' curlies are for hash references or for code blocks. Constructing and destroying a hash to pass named params is just silly. See also my answer to AnomalousMonk.

Re^2: Preferred technique for named subroutine parameters? (PBP)
by AnomalousMonk (Archbishop) on May 22, 2009 at 21:45 UTC
    Actually, I was pretty sure I had read it somewhere, I was just too lazy to look it up; but I knew it worked!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found