perl use uninitialized value,之前运行Ok的,不影响结果但多出来很多这样语句.Use of uninitialized value in split at /ShipWeb.pm line 84.Use of uninitialized value in split at /ShipWeb.pm line 85.Use of uninitialized value in split at
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/07 16:56:43
perl use uninitialized value,之前运行Ok的,不影响结果但多出来很多这样语句.Use of uninitialized value in split at /ShipWeb.pm line 84.Use of uninitialized value in split at /ShipWeb.pm line 85.Use of uninitialized value in split at
perl use uninitialized value,之前运行Ok的,不影响结果但多出来很多这样语句.
Use of uninitialized value in split at /ShipWeb.pm line 84.
Use of uninitialized value in split at /ShipWeb.pm line 85.
Use of uninitialized value in split at /ShipWeb.pm line 86.
Use of uninitialized value in split at ShipWeb.pm line 87.
Use of uninitialized value in split at ShipWeb.pm line 88.
82 foreach my $i (0..$#list){
83 ($sShip,) = split(/ /,$list[$i]{$column[0]});
84 ($PN,) = split(/ /,$list[$i]{$column[1]});
85 ($Lcycle,) = split(/ /,$list[$i]{$column[2]});
86 ($WIPrev,) = split(/ /,$list[$i]{$column[3]});
87 ($FGIrev,) = split(/ /,$list[$i]{$column[4]});
88 ($ShipMode,) = split(/ /,$list[$i]{$column[5]});
89 if ($ShipMode){
90 print FH "$sShip|$PN|$Lcycle|$WIPrev|$FGIrev|$ShipMode\n";}
91 }
perl use uninitialized value,之前运行Ok的,不影响结果但多出来很多这样语句.Use of uninitialized value in split at /ShipWeb.pm line 84.Use of uninitialized value in split at /ShipWeb.pm line 85.Use of uninitialized value in split at
1) 定义 $column 的时候,把字串写错了.
For example:----------
$list[$i]->{col1} = 1
$list[$i]->{col2} = 2
$list[$i]->{col3} = 3
$list[$i]->{col4} = 4
$list[$i]->{col5} = 5
$column[0] = "col1"
$column[0] = "xol2"
$column[0] = "xol3"
$column[0] = "xol4"
$column[0] = "xol5"
----------------------------
2) 定义 $list 的时候,hash key 没有正确的定义.
$list[$i]->{xol2} = 2
$list[$i]->{xol3} = 3
等等.
解决方法:
在for前一行写上如下两行.然后实行一下,再看看error log file.
#use Data::Dumper;
warn Dumper $list[0]; #$list的第一个要素肯定存在.
warn Dumper @column;
die;
你看看list中的 hash key 和 @column 中定义的 key 是否相同.
回避方法:
把有可能出错的地方都实行一下 if defined .
if( defined $list[$i]{$column[1]} ) {
( $PN ,) = split( / / ,$list[$i]{$column[1]} );
}