【发布时间】:2011-06-09 14:20:47
【问题描述】:
如何将标量变量和数组变量都传递给 Perl 中的子例程?
my $currVal = 1;
my $currValTwo = 1;
my @currArray = ('one','two','three');
my @currArrayTwo =('one','two','three');
&mysub($currVal, $currValTwo,\@currArray, \@currArrayTwo);
sub mysub() {
# That doesn't work for the array as I only get the first element of the array
my($inVal, $inValTwo, @inArray, @inArrayTwo) = @_;
}
【问题讨论】:
-
哪个数组,你用的是两个?
-
两者都发生了,但 Blagovest 的回答修复了它!
-
我整天都在寻找这个问题。谢谢你问这个!!!
标签: perl