See this as a poll, but also as a request for discussion. If I've missed a previous thread, please let me know.
How do you do named arguments in Perl 5?
Do you use a hash? A module to check things? Maybe a source filter? Do warn or die or do nothing at all, in case of unknown keys?
Please provide an example of how you would handle this contrived and simple case, as a teaser presented in Perl 6:
The sub &convert requires exactly three named arguments (as indicated by the colons): from, to, and thing. They have to be specified (as indicated by the exclamation points), but may be undef. Of course, if you don't check for these things usually, don't include checks in your example. Here, the arguments are accessible through $from, $to and $thing in the sub itself, but if you access things through a hash, leave it that way.sub convert (:$from!, :$to!, :$thing!) { ... }
If you use a hash, what is it called? arg? argv? args? param? params? %_? Is it copied from @_, or do you require the caller to pass a reference? Do you allow both?
It'll be interesting to see the colorful spectrum of what we all use.
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
In reply to Your named arguments by Juerd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |