hi, try this:

print $_ foreach @array;

2011/7/1 Gary.jsz <[email protected]>

> **
>
> 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
>
>  --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>



-- 
+++++++_++++++++
李 镇
DeNA China 智能手机事业部
(86-21-6267-6611-137)

大家一起来玩[梦宝谷]吧!
http://mobage.com.cn

++++++ *-* +++++++

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复