You misunderstood the purpose of the warnings
pragma. It is there to emit a warning message for completely legal, but possibly wrong operations. Example:
use warnings;
my ($x, $y) = ("hello", "world");
say "same" if $x == $y;
→ Argument "world" isn't numeric…
. We can make certain categories produce fatal errors with use warnings FATAL => $CATEGORY
with categories like numeric
or uninitialized
. The all
category represents all categories.
It does not change the semantics of every warn
to die
. You can do this yourself, e.g. with overriding a local $SIG{__WARN__}
, or creating a warn
function that does croak @_
. You can even override CORE::GLOBAL::warn
to change all warn
s, even if they are in other modules.
The CGI::Carp
module has a warningsToBrowser
option; you may want to look at the source code to see how it's implemented.