toolic的答案use warnings FATAL => 'all';
是正确的,但有一些警告。内部perl函数发出了一些警告,这些警告确实不会消失。在中列出了这些不安全的致命警告perldoc strictures
。
从版本2.000003开始strictures
,它启用以下警告:
use warnings FATAL => 'all';
use warnings NONFATAL => qw(
exec
recursion
internal
malloc
newline
experimental
deprecated
portable
);
no warnings 'once';
Run Code Online (Sandbox Code Playgroud)
有关完整的原理,请参见https://metacpan.org/pod/strictures#CATEGORY-SELECTIONS。
当然,除了将以上几行复制/粘贴到您的代码中之外,您还可以
use strictures 2;
Run Code Online (Sandbox Code Playgroud)
这也strict
为您启用。(不过,您可能必须先安装strictures
。)