=encoding utf-8 =head1 NAME Sub::Params - Handle function arguments =head1 SYNOPSIS 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 }); =head1 DESCRIPTION Module contains functions helping dealing with parameters. =head2 named_or_positional_arguments( args => [], names => [] ) 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: =over =item args Reference to argument array =item names Positional argument names in form used in named arguments call =back Function recognizes named arguments when: =over =item every odd parameter is name from names list =item first and only argument is hashref with keys from names list =back Uses Hash::Util::lock_keys to detect valid names. =head1 ACKNOWLEDGMENTS Thanks L<< GoodData|https://gooddata.com >> for supporting open-source contribution =head1 SUPPORT This module comes with no warranty and is distributed as is. To participate please use discussions using project's github issues. =head1 REPOSITORY https://github.com/gooddata/perl-sub-params =head1 LICENSE 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: L