perl 子程序传递多个数组到底怎么玩
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向子程序传递多个数组及使用方法
#!/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向子程序传递多个数组及使用方法
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询