我基本上有以下perl我正在使用:
open I,$coupon_file or die "Error: File $coupon_file will not Open: $! \n";
while (<I>) {
$lctr++;
chomp;
my @line = split/,/;
if (!@line) {
print E "Error: $coupon_file is empty!\n\n";
$processFile = 0; last;
}
}
Run Code Online (Sandbox Code Playgroud)
如果给出一个空文件,我无法确定split /,/函数返回的内容.代码块if(!@line)永远不会被执行.如果我改变它
if (@line)
Run Code Online (Sandbox Code Playgroud)
比执行代码块.我读过的关于perl的分割功能对信息 http://perldoc.perl.org/functions/split.html和讨论,这里大约测试空数组,但不知道是怎么回事.
我是Perl的新手,所以我可能在这里错过了一些简单明了的东西.