[perl] out() -- function
一、源码
1 #!/usr/bin/perl
2
3 # perl_file = xx.pl
4
5 # name: out()
6 # function: print all elements of array of input parameters.
7 # return: none
8 sub out {
9 $i = 0;
10 foreach (@_)
11 {
12 print "element[$i] := " . $_ . "\n" ;
13 $i++ ;
14 }
15 $i = 0 ;
16 }
17
18 # running part
19 @world = qw/tang-xuanzang sun-wukong zhu-wuneng sha-wujing/ ;
20 out ( @world ) ;
二、输出
1 element[0] := tang-xuanzang
2 element[1] := sun-wukong
3 element[2] := zhu-wuneng
4 element[3] := sha-wujing
三、参考资料
1、 特殊变量【@_】 -- https://perldoc.perl.org/perlsub
2、 数组【qw//】 -- https://www.runoob.com/perl/perl-arrays.html
本文由 lnlidawei 原创、整理、转载,本文来自于【博客园】; 整理和转载的文章的版权归属于【原创作者】; 转载或引用时请【保留文章的来源信息】:https://www.cnblogs.com/lnlidawei/p/17991048