Perinci::Sub::ConvertArgs::Array - Convert hash arguments to array
This document describes version 0.08 of Perinci::Sub::ConvertArgs::Array (from Perl distribution Perinci-Sub-ConvertArgs-Array), released on 2015-12-29.
use Perinci::Sub::ConvertArgs::Array qw(convert_args_to_array); my $res = convert_args_to_array(args=>\%args, meta=>$meta, ...);
This module provides convert_args_to_array() (and gencode_convert_args_to_array(), upcoming). This module is used by, among others, Perinci::Sub::Wrapper.
Convert hash arguments to array.
Using information in 'args' property (particularly the 'pos' and 'greedy' of each argument spec), convert hash arguments to array.
Example:
my $meta = { v => 1.1, summary => 'Multiply 2 numbers (a & b)', args => { a => ['num*' => {arg_pos=>0}], b => ['num*' => {arg_pos=>1}], } }
then 'convert_args_to_array(args=>{a=>2, b=>3}, meta=>$meta)' will produce:
[200, "OK", [2, 3]]
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
args* => hash
meta* => hash
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.
Return value: (any)
Please visit the project's homepage at https://metacpan.org/release/Perinci-Sub-ConvertArgs-Array.
Source repository is at https://github.com/sharyanto/perl-Perinci-Sub-ConvertArgs-Array.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Sub-ConvertArgs-Array
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.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2015 by 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.
To install Perinci::Sub::ConvertArgs::Array, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perinci::Sub::ConvertArgs::Array
CPAN shell
perl -MCPAN -e shell install Perinci::Sub::ConvertArgs::Array
For more information on module installation, please visit the detailed CPAN module installation guide.