Chinaunix首页 | 论坛 | 博客
  • 博客访问: 966226
  • 博文数量: 184
  • 博客积分: 10030
  • 博客等级: 上将
  • 技术积分: 1532
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-27 18:32
文章分类

全部博文(184)

文章存档

2009年(1)

2008年(63)

2007年(39)

2006年(79)

2005年(2)

我的朋友

分类:

2007-01-03 11:20:07

传递给子程序的参数列表放在一个名为@_的列表中。
 
#!/usr/bin/perl
# Fig 6.5: fig06_05.pl
# Demonstrating a subroutine that receives arguments.
displayArguments( "Sam", "Jones", 2, 15, 73, 2.79 );
# output the subroutine arguments using special variable @_
sub displayArguments
{
   # the following statement displays all the arguments
   print "All arguments: @_\n";
   # the following loop displays each individual argument
   for ( $i = 0; $i < @_; ++$i ) {
      print "Argument $i: $_[ $i ]\n";
   }
   $i = 0;
   for(@_) {
      print "\$_ is: $_\n";
      print "\$_[\$i] is: $_[$i]\n";
      ++$i;
   }
}
阅读(1512) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~