Perinc...::Args(3pm)
π Perinci::Sub::Util::Args π
okay bestie, welcome to Perinci::Sub::Util::Args (that's the 3pm one, perl's very own corner of the manual-verse π«Ά). It's a little toolbox of utility routines that do stuff with Rinci arguments, and honestly? it's giving "small but mighty". let's get into it β¨
β¨ NAME β¨
Perinci::Sub::Util::Args β utility routines related to Rinci arguments. that's the whole vibe, no notes π
πΈ VERSION πΈ
this doc describes version 0.472 of Perinci::Sub::Util::Args (coming at you from the Perl distribution Perinci-Sub-Util), and it was released on 2023-10-28. mark the calendar bestie π
π¦ SYNOPSIS π¦
here's the whole thing in action, copy it, paste it, live your truth:
package MyPackage;
use Perinci::Sub::Util::Args qw(
args_by_tag
argnames_by_tag
func_args_by_tag
func_argnames_by_tag
call_with_its_args
);
our %SPEC;
my %func1_args;
$SPEC{myfunc1} = {
v => 1.1,
summary => 'My function one',
args => {
%func1_args = (
foo => {tags=>['t1', 't2']},
bar => {tags=>['t2', 't3']},
baz => {},
),
},
};
sub myfunc1 {
my %args = @_;
}
$SPEC{myfunc2} = {
v => 1.1,
summary => 'My function two',
args => {
%func1_args,
qux => {tags=>['t3']},
},
};
sub myfunc2 {
my %args = @_;
my $res = call_with_its_args('myfunc1', \%args);
}
π DESCRIPTION π
literally just the functions section. that's it. that's the description. the functions ARE the description, iykyk π
π FUNCTIONS π
π args_by_tag
usage, bestie:
my %args = args_by_tag($meta, \%args0, $tag);
what it does: it will select only the keypairs from %args0 arguments that have the tag $tag. so it's like a vibe check but for args π«Ά
examples, because examples are iconic:
my %args = args_by_tag($SPEC{myfunc1}, {foo=>1, bar=>2, baz=>3, qux=>4}, 't2'); # (foo=>1, bar=>2)
πΈ argnames_by_tag
usage:
my @arg_names = argnames_by_tag($meta, $tag);
it will select only the argument names which have the tag $tag. names only, no values, we're being minimal and mysterious β¨
π¦ func_args_by_tag
usage:
my %args = func_args_by_tag($func_name, \%args0, $tag);
it's like args_by_tag except that instead of handing over Rinci function metadata, you supply a function name. Rinci metadata will be searched in the %SPEC variable. detective mode fr fr π
π
func_argnames_by_tag
usage:
my @argnames = func_argnames_by_tag($func_name, $tag);
like argnames_by_tag except that instead of handing over Rinci function metadata, you supply a function name. Rinci metadata will be searched in the %SPEC variable. same deal, name edition π
π«Ά call_with_its_args
usage:
my $res = call_with_its_args($func_name, \%args);
call the function with arguments taken from %args. only the arguments which the function declares it accepts will be passed β everything else gets politely left at the door. no gatecrashing π
π HOMEPAGE π
please visit the project's homepage at <https://metacpan.org/release/Perinci-Sub-Util>. go on, it's right there π
β SOURCE β
source repository is at <https://github.com/perlancar/perl-Perinci-Sub-Util>. the code lives there, no cap π§
π AUTHOR π
perlancar <perlancar@cpan.org>. absolute legend, we stan π
π CONTRIBUTING π
to contribute, you can send patches by email/via RT, or send pull requests on GitHub. all approaches valid, pick your main character moment π
most of the time, you don't need to build the distribution yourself. you can simply modify the code, then test via:
% prove -l
if you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. any additional steps required beyond that are considered a bug and can be reported to me. yes, a bug, fr fr π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2023, 2020, 2017, 2016, 2015, 2014 by perlancar <perlancar@cpan.org>.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in freedom, slay π
π BUGS π
please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Sub-Util>.
when submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. this part is not optional bestie, it's literally the whole thing π
and that's the page! this little beauty shipped with perl v5.38.2 and was dated 2024-05-26. go forth and tag your args, bestie πβ¨ππ¦πΈ
π¦ where this page comes from
- debian trixie: libperinci-sub-util-perl 0.472-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libperinci-sub-util-perl 0.472-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libperinci-sub-util-perl 0.472-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms