My preference is a single hash ref for options with an explicit "1" for Boolean options: subr( { this=>1, that=>[ 5, 6 ], other=>'/path/etc/foo' } )
I prefer the hash ref for several reason. It requires the caller to put in the { and } which let's Perl catch if they put in a odd number of arguments. It fits in well with routines that have some required arguments besides the hash options. It makes it easier to extend the interface in the future. One routine can just pass the same options along to another without any copying involved. It makes validating the passed-in arguments easier [just UNIVERSAL::isa($opts,"HASH")]. It forces your code to not depend on the order in which the options are listed.
One disadvantage is that you should be careful to avoid having your routine modify the ref'd hash.
- tye (but my friends call me "Tye")In reply to (tye)Re: Ways of Passing Configuration Parameters
by tye
in thread Ways of Passing Configuration Parameters
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |