hermida has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone, searching CPAN I cannot find a recently maintained library to support named subroutine arguments/parameters. What CPAN library is recommended?
The overhead introduced by most of these modules is quite significant as they make several subroutine calls for every argument processed under the hood. That may be admissible or not for your particular case.
This is my preferred way of handling named parameters:
sub foo {
my ($self, %opts) = @_;
my $foo = delete $opts{foo} // 'default_foo';
my $bar = delete $opts{bar} // croak "required parameter bar missing
+";
...
%opts and croak_bad_args(\%opts);
...
}
Why would you only be interested in stuff that has been updated recently? If it's old, that is more likely to mean "it just works" than "it's been abandoned and is full of bugs".
That is absolutely true, just wanted to make sure that when I select a certain CPAN library to use and include in my software distribution that it's not obsolete, or not maintained, etc. But you are right if it just works then I shouldn't care so much :-)