As wfsp has said, you can just assign @_ and this will treat the passed list of parameters as a set of key and value pairs. Note that an odd number of params will result in a run time exception.
But, you often want to perform some (often elementary) validation on the input parameters, before casting them to a hash, such as checking that the keys are what you expect. Params::Validate is what I tend to use to do this, though there are other CPAN modules which do similar things. There are plenty of examples of how to use it in the docs.
--
Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)
In reply to Re: Passing hashes as arguments to a sub?
by rinceWind
in thread Passing hashes as arguments to a sub?
by Spidy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |