传数组引用,在子函数中,接受到引用后,再解引用。
sub func
{
my($a,$b,$c) = @_; # 这里$b,$c接受到的是数组的引用
print "$a\n";
my $count = 0;
while($count < @$b) #这里解引用
{
print "$b->[$count]\n";
$count++;
}
$count = 0;
while($count < @$c) #这里解引用
{
print "$c->[$count]\n";
$count++;
}
}
my @arry1 = ("fff", "rrr", "www");
my @arry2 = ("ttt", "hhh", "ccc");
func("qqq", \@arry1, \@arry2); # 这里传入数组的引用