in reply to Returning through signal

You can use die for this. You can make a handler for die like this:

$SIG{__DIE__} = sub { # do something };
Look at the perlvar manpage for discussions of the %SIG hash. Note that your die handler will also be called in the case of die from evals; you may need to check $^S for this (it will be true inside an eval).