我花了一段时间才找到我的代码突然出现的问题,但 WWW::Mechanize::GZip 似乎以某种方式触发了我的 $SIG{ 模具 } 处理程序。考虑这个代码:
use strict;
use WWW::Mechanize::GZip;
$SIG{__DIE__} = sub {
print "WTF??? WHY IS THIS BEING TRIGGERED?\n";
};
my $mech = WWW::Mechanize::GZip->new();
$mech->get( 'http://ammoseek.com/' );
print $mech->content(), "\n";
知道为什么会发生这种情况吗?我能做些什么来防止它?
谢谢,
-麦克风
最佳答案
您可以通过 $SIG{__DIE__}
了解死亡原因/死亡原因的详细信息。处理程序打印:
$_[0]
)Carp::cluck
) 或者,使用
onerror => \&func
WWW::Mechanize::GZip 构造函数的参数以创建自定义错误处理程序(假设错误不是来自 Compress::Zlib)。来自 WWW::Mechanize PODonerror => \&func
Reference to a die-compatible function, such as Carp::croak, that is called when there's a fatal error.
If this is set to undef, no errors will ever be shown.
If this value is not passed, Mech uses Carp::croak if Carp is installed, or CORE::die if not.
由于 WWW::Mechanize::GZip 是 WWW::Mechanize 的直接子类,您可以使用相同的参数来构造它。
关于perl - WWW::Mechanize::GZip 触发 __DIE__ 信号......为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2976344/