in reply to Re: Capturing Text from a die command
in thread Capturing Text from a die command
Note that die is often caught in eval, and you usually don't want to log such fake deaths. You can avoid that by checking $^S:
$SIG{__DIE__} = sub { die @_ if $^S; ... };
Note that the fake SIG handlers __DIE__ and __WARN__ have special handling: the handler is suspended while running it, so calling die() within the die handler does the right thing.
This still won't necessarily do the right thing for the commonish idiom of 'load module if available':
since in that context $^S is set to undef; I'm not aware of any easy way to determine in that case whether or not the failed require is happening inside an eval.BEGIN { $module_loaded = eval { require Some::Module }; }
Hugo
|
|---|