package ExitIgnorer; use 5.10.0; use Exporter qw(import); @EXPORT = qw(ignore_exit_calls restore_exit_calls); our $ignoreExit = 0; *CORE::GLOBAL::exit = sub { if ($ignoreExit) { say "exit(", join(",", map "'$_'", @_), ") sub "; } else { CORE::exit(@_); } }; sub ignore_exit_calls { $ignoreExit = 1; } sub restore_exit_calls { $ignoreExit = 0; } 1;