use of uninitialized value $line in scalar chomp at 2.3.pl line 10,是哪里出了错?use strict;use warnings;open IN_FILE,"

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/14 05:25:56

use of uninitialized value $line in scalar chomp at 2.3.pl line 10,是哪里出了错?use strict;use warnings;open IN_FILE,"
use of uninitialized value $line in scalar chomp at 2.3.pl line 10,是哪里出了错?
use strict;
use warnings;
open IN_FILE,"

use of uninitialized value $line in scalar chomp at 2.3.pl line 10,是哪里出了错?use strict;use warnings;open IN_FILE,"
"use of uninitialized value $line" 说你在第10行使用了未定义的值$line ;
09.$line = ; # while循环到最后一行后,没有退出,还要再读入
10.chomp($line); #读入的内容为空,即$line未定义
改成下面的方式:
while(1){
$line = ;
if(not defined($line)){
\x05last;
}
chomp($line);
print "$line ";
$a=$a+$line;
$number++;
}
所以先进行判断,$line是否有值,无则退出
尽管不知道你在考什么,但是大概明白了这是在求一个txt文件中一列数字的平均数