in reply to Chaining/Stacking $SIG{__WARN__}
That depends on what you mean by play nicely. This will restore the previous signal handlers after leaving your function.
If you want to have your handler called and then the original then you will need to do a bit more worksub do_something { local $SIG{__WARN__} = sub { ... }; # your stuff goes here ... } # previous version restored
my $old_warn = $SIG{__WARN__}; $SIG{__WARN__} = sub { # your stuff $old_warn->(@_); }
|
|---|