6

这个脚本:

use warnings FATAL => 'all';

warn 'warning';
die 'death';

...导致“警告”被记录下来,但此时并没有死去,而是死于“死亡”。

我有一个 mod_perl 模块,它在开发过程中覆盖$main::SIG{__DIE__}到基本上向浏览器吐出 die() 消息,但它没有 touch SIG{__WARN__},那么这里发生了什么?

这是在 Windows Server 2003 上的 perl 5.10.1 上,在 PerlSwitches 中带有“-w”。

4

2 回答 2

11

It doesn't seem to work because your test isn't testing what you want to test. Try this:

use warnings FATAL => 'all';

print undef;
die 'death';

Just as a no warnings will not prevent warn from working, warnings FATAL will not make warn die.

于 2013-06-11T15:08:01.903 回答
9
于 2013-06-11T15:07:49.047 回答