How do I pass an aliased array reference in a MooseX::Method::Signatures method?

97 views Asked by At

MooseX::Method::Signatures should be able to obtain an array reference as a parameter and use it as a normal array within the method, see Aliased references in Method::Signatures.

Using the code in the documentation as an example, I've written:

package MethodSignatures;

use strict;
use warnings;

use Moose;
use MooseX::Method::Signatures;

method add_one(\@foo) {
    $_++ for @foo;
}

my @bar = ( 1, 2, 3 );
MethodSignatures->add_one(\@bar);    # @bar is now (2,3,4)

However, it fails with:

')' expected whilst parsing signature near '@foo' in '\@foo' at d:/workspace/lib/tools/Perl/site/lib/MooseX/Method/Signatures/Meta/Method.pm line 199

Is this because I am using Perl 5?

1

There are 1 answers

0
bvr On BEST ANSWER

Please note that MooseX::Method::Signatures is something different from Method::Signatures. The former does not mention \@foo syntax as allowed for prototype, so it may be reason for fail.

Both modules are for perl 5, so this should not be reason for the error.