我最近遇到一个错误,use warnings FATAL ...
编译指示将来自其他地方的静音警告解释为死亡原因。使用关于整个项目的警告同样的政策致命未初始化警告 - 在远处采取行动
use strict;
# In one file:
no warnings;
my %hash;
Foo->bar(my $temp = $hash{ +undef }); # this lives
Foo->bar($hash{ +undef }); # this dies
# Elsewhere
package Foo;
use warnings FATAL => qw(uninitialized);
sub bar {
my ($self, $param) = @_; # prefectly safe
$param = "(undef)"
unless defined $param; # even safer
print "Param: $param\n";
}
现在,这当然可以固定大的时候:考虑下面的示例。或者可以通过排除特定位置的undefs来解决这个问题(参见# this lives
一行)。
我的问题是Foo包是否有一个可接受的解决方案,它不需要改变调用它的任何东西,以及这是否真的是Perl本身的错误。
难以置信。至少现在开始有意义了...... – Dallaylaen