truncatei,您好!
谢谢!
如果返回一个数组该怎么遍历打印?
比如:
sub output{
my @arra = (a, b, c, d, e, f, g);
my $host_name = 12345;
my $kernel = "2.6.35";
my $version = "Redhat enterprise linux";
#print "$host_name\n $kernel\n $version\n";
return (@arra, $host_name, $kernel, $version);
}
因为数据的元素个数未知,从文件中获取的。
======= 2011-06-30 18:46 truncatei 您在来信中写到:Re: [PerlChina] 子例程问题,请教 =======
做法有很多种,比如:
sub output{
my $host_name = 12345;
my $kernel = "2.6.35";
my $version = "Redhat enterprise linux";
#print "$host_name\n $kernel\n $version\n";
return ($host_name, $kernel, $version);
}
my @result = output();
print $result[1];
----
Gary.jsz
Gary.jsz
没有评论:
发表评论