MooseX::Method::Signatures应该能够获取数组引用作为参数并将其用作方法中的普通数组,请参阅Method::Signatures 中的别名引用。
以文档中的代码为例,我编写了:
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)
但是,它失败了:
')' expected whilst parsing signature near '@foo' in '\@foo' at d:/workspace/lib/tools/Perl/site/lib/MooseX/Method/Signatures/Meta/Method.pm line 199
这是因为我使用的是 Perl 5 吗?