I have 2 lines next to each other in a Perl script that can trigger __WARN__. If the first one throws, then I just want to return from the function and not try to continue.
I know how to set up a handler before both lines so that I can report an error, etc:
local $SIG{__WARN__} = sub {
my $e = shift;
return;
};
But then this happens for both lines. I would prefer it to just catch the first instance and return from the function. But returning in this handler returns a handler, not an external function.
Is there a way to return from a function when processing a signal?
source
share