考虑以下傻Perl程序:如何在Perl中为<>混合命令行参数和文件名?
$firstarg = $ARGV[0];
print $firstarg;
$input = <>;
print $input;
我从终端运行,如:
perl myprog.pl sample_argument
而得到这个错误:
Can't open sample_argument: No such file or directory at myprog.pl line 5.
任何想法,这是为什么?当它到达<>它试图从(不存在的)文件中读取“sample_argument”或什么?为什么?
啊哈!更改为工作正常:) –
Jimmeh
2010-02-26 21:31:52