小骆驼 第五章 输入与输出

调用参数

1.txt
ssssssssssss
ssssssssss
dddddddddddd
2222222222
sssssssssssssssss
#!/usr/bin/perl

use strict;
use warnings;

while(<>)
{
    chomp;
    $_ = <>;
    print "$_";
}

##ssssssssss
##2222222222
##Use of uninitialized value $_ in string at test.pl line 10, <> line 5.

print "$0\n";

##test.pl

问题一:文件无法传入


@ARGV = (1.txt,2.txt,3.txt);

while(<>)
{
    chomp;
    $_ = <>;
    print "$_";
}

##Bareword found where operator expected at test.pl line 6, near "1.txt"
        (Missing operator before txt?)
##Bareword found where operator expected at test.pl line 6, near "2.txt"
        (Missing operator before txt?)
##Bareword found where operator expected at test.pl line 6, near "3.txt"
        (Missing operator before txt?)
##syntax error at test.pl line 6, near "1.txt"
##Execution of test.pl aborted due to compilation errors.

原文地址:https://www.cnblogs.com/yuanjingnan/p/11061478.html