perl 子程序传递多个数组到底怎么玩

2024-11-15 13:48:51
推荐回答(1个)
回答(1):

示例:
#!/usr/bin/perl -w
use strict;
my @array1 = (["a","b","c"],["d","e","f"],["g","h","i"]);
my @array2 = (["a","b","c"],["d","e","f"]);
&test (\@array1, \@array2);
&test (\@array1, \@array2);
sub test
{
my ($subarray1, $subarray2) = @_;
print "$$subarray1[0][0]"."\n";
print "$$subarray2[0][0]"."\n";
print $#{$subarray1},"\n";
print $#{$subarray2},"\n";
print $#{$$subarray1[0]},"\n";
print $#{$$subarray2[0]},"\n";
}
输出结果:
a
a
2
1
2
2
a
a
2
1
2
2
以便照葫芦画瓢
perl向子程序传递多个数组及使用方法perl向子程序传递多个数组及使用方法