No such thing as a small change | |
PerlMonks |
Re: Passing hashes as arguments to a sub?by jimbojones (Friar) |
on Nov 28, 2005 at 21:30 UTC ( [id://512385]=note: print w/replies, xml ) | Need Help?? |
Hi TheDamian's new book, Perl Best Practices, covers this in Chapter 9. He recommends passing a hash reference, typically to an anonymous hash.
The reasons given for not passing a list of raw key/value pairs is: Requiring the named arguments to be specified inside a hash ensures that any mismatch, such as:The chapter on subroutines is currently available as a sample chapter on the O'Reilly website for you to peruse. It's a great book, highly recommended.will be reported (usually at compile time) in the caller’s context: - j
In Section
Seekers of Perl Wisdom
|
|