in reply to Best CPAN library for named subroutine arguments/parameters
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); ... }
It requires some more coding but is cheap.
|
|---|