Use of uninitialized value in string eq. left or right?
I am clearing up some code and I see in our server logs that the perl error is ...
Use of uninitialized val开发者_开发问答ue in string eq at .....
Looking at the code the line looks like this....
if ($level1 eq $level2) {
OK fair enough. I suppose my question is this. Is it $level1 or $level2 that's the problem?
I wrote a quick test to try to replicate it locally and it looks like this....
#!/usr/bin/perl
use warnings;
my $a;
my $b;
if ($a eq $b){
print "....";
}
And I get a much more informative error.
Use of uninitialized value $a in string eq at ./warntest.cgi line 7.
Use of uninitialized value $b in string eq at ./warntest.cgi line 7.
This is seemingly inconsistent behavior. Does anyone have a clue? Janie
The indication of which variable was undef was added to the warning (where easily possible) in perl 5.10 (to much cheering). Your server is likely using an older perl.
精彩评论