小编Vas*_*Vas的帖子

Perl警告:在连接或字符串中使用未初始化的值

我越来越:

"Use of uninitialized value in join or string at ./test_script.pl line 69, <fh> line 91."
Run Code Online (Sandbox Code Playgroud)

创建此警告的代码如下:

# Write results of SQL execution to output file
if ($@) { print "\n DB Error : ", $@; exit; }
open(FH, ">$output_file") or 
        die "\n cannot write to the file $output_file. Check the file permissions";
while(my @row= $sth->fetchrow_array) {
      print FH join($delimiter, @row). "\n";
}
Run Code Online (Sandbox Code Playgroud)

它来自"while"块中的"print ... join ...."行,但我不确定100%是由什么引起它以及如何纠正它.

$ delimiter先前初始化$ delimiter ="|" 并且@row从前一行的$ sth操作中获取其值.

这是关于@row值的"时间"问题还是正在处理的实际SQL查询文件中的某些内容,如警告的"<fh>第91行"部分所示?关于如何避免警告的任何想法?顺便说一下,脚本工作正常,它只是为每个获取的@row值生成一个警告,这会在大数据集拉动时产生大量警告......

perl warnings dbi

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

dbi ×1

perl ×1

warnings ×1