The first example is probably OK as long as your check against $@ is both strict enough and liberal enough to not be confused by the stack trace. The second example has a bigger problem, eval {foo} works but foo() on it's own doesn't give a stack trace.
The solution is not a one-liner, it needs to pay attention to $^S which indicates whether we're being eval()ed or not. It should also play well with other die/warn handlers. diagnostics does this. I'll submitting a small patch to add stack traces to warns and to allow a mode that turns off the verbose explanations, then I'll be happy.
In reply to Re^4: Automatic stack traces for warns and dies
by fergal
in thread Automatic stack traces for warns and dies
by fergal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |