DESCRIPTION

A

Here's a normal Perl module:

package MyModule;

sub pow {
    my ($base, $exp) = @_;
    $base ** $exp;
}

1;

Here's a Perl module after we add some metadata and do a few adjustments:

package MyModule;

our %SUB_EXTRAS;
$SUB_EXTRAS{pow} = {
    desc => 'Exponent a number',
    args => {
        base=>[float=>{desc=>'Number to exponent', required=>1, arg_pos=>1}],
        exp =>[float=>{desc=>'The exponent'      , required=>1, arg_pos=>2}],
    },
    return => [float]
};

sub pow {
    my (%args) = @_;
    $args{base} ** $args{exp};
}

1;

There are some differences:

  • $SUB_EXTRAS{pow}

  • Accept arguments

  • Return result in an array form