Chinaunix首页 | 论坛 | 博客
  • 博客访问: 267631
  • 博文数量: 3
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 37
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-04 15:12
文章分类

全部博文(3)

文章存档

2019年(1)

2014年(2)

我的朋友

分类: Windows平台

2014-04-23 14:25:51



好拗口啊。。。

ARGV

    [ALL] The special filehandle that iterates over command-line filenames in @ARGV. Usually written as the null filehandle in the angle operator: <>.
$ARGV

    [ALL] Contains the name of the current file when reading from the ARGV handle using the <> or readline operators.
@ARGV

    [ALL] The array containing the command-line arguments intended for the script. Note that $#ARGV is generally the number of arguments minus one, since $ARGV[0] is the first argument, not the command name; use scalar @ARGV for the number of program arguments. See $0 for the program name.


$ARGV跟ARGV都是跟<>钻石操作符有关系的

@ARGV保存了命令行的所有参数


比如 test.pl  1.txt 2.txt

@ARGV  为(1.txt, 2.txt)

程序里如果写
while (<>) {
      print "from file $ARGV  get line:" , $_, "\n"; 
}

将依次读入1.txt, 2.txt, 并依次读入每一行。 $ARGV表示当前正在读取的文件名, ARGV表示当前正在读取的文件句柄。
阅读(1774) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:【Perl编程金典】特殊变量@ARGV和<>

给主人留下些什么吧!~~