Sub::Params - Handle function arguments
use Sub::Params qw[ named_or_positional_arguments ]; sub foo { my ($self, @args) = @_; my %args = named_or_positional_arguments( args => \@args, names => [qw[ foo bar baz]], ) } # following calls are equivalent in behavior foo( 1, 2, 3 ); foo( foo => 1, bar => 2, baz => 3 ); foo( { foo => 1, bar => 2, baz => 3 });
Module contains functions helping dealing with parameters.
Helps coversion from positional to named arguments.
Use it only for minimal transition period, it is not intended for permanent usage.
Takes reference to actual function arguments and names in order of positional interface.
Parameters:
Reference to argument array
Positional argument names in form used in named arguments call
Function recognizes named arguments when:
Uses Hash::Util::lock_keys to detect valid names.
Thanks GoodData for supporting open-source contribution
This module comes with no warranty and is distributed as is.
To participate please use discussions using project's github issues.
https://github.com/gooddata/perl-sub-params
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
To install Sub::Params, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Params
CPAN shell
perl -MCPAN -e shell install Sub::Params
For more information on module installation, please visit the detailed CPAN module installation guide.