Sig::PackageScoped::Paranoid - All $SIG{__DIE__} and $SIG{__WARN__} assignments are module-scoped
use Sig::PackageScoped::Paranoid; package Foo; $SIG{__DIE__} = sub { die "in Foo" }; package Bar; die "not in Foo";
Whenever a handler is assigned $SIG{__DIE__} or $SIG{__WARN__} the effects are now scoped to the package that did the assignment.
$SIG{__DIE__}
$SIG{__WARN__}
This module needs to be loaded before any other module that assigns to $SIG{__DIE__} or $SIG{__WARN__} for this to work.
This will catch any attempt to set $SIG{__DIE__} or $SIG{__WARN__} and force it to be package-scoped. This will probably break things like CGI::Carp so use it with care. OTOH, modules that globally set these signals deserve to be broken.
CGI::Carp
The fact that this works scares me deeply. It is not recommended that you use this code in any sort of production environment.
Dave Rolsky <autarch@urth.org>
To install Sig::PackageScoped, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sig::PackageScoped
CPAN shell
perl -MCPAN -e shell install Sig::PackageScoped
For more information on module installation, please visit the detailed CPAN module installation guide.