A better stack trace then my previous attempt: Trace Warnings
This one uses Carp as per merlyn's suggestion.
use Carp; # Fatal stack trace made non-fatal. eval q{confess('Stack Trace')}; print $@; # $@ is set by eval().
You can put the last two lines anywhere to get a stack trace to that point. So if you had a weird warning (the reason for my previous attempt) you could set $SIG{__WARN__} to that two line sub-routine.

That may seem trivial, but it took me awhile to have that light-bulb come on... so I thought I would post it.

Replies are listed 'Best First'.
RE: Stack Trace
by japhy (Canon) on Oct 21, 2000 at 03:24 UTC
    Hate to burst your bubble... but cluck() is the non-fatal equivalent to confess()...

    $_="goto+F.print+chop;\n=yhpaj";F1:eval
      not quite. cluck() goes to STDERR (via warn). Doing it my way gets the stack trace into a variable, namely $@, and this means I can do whatever I want with it, without having to redirect STDERR. :-)
        Ok, fine. You win this time, Trebek.

        $_="goto+F.print+chop;\n=yhpaj";F1:eval