in reply to Automatic stack tracebacks in warnings?

Does the cluck() function in Carp do what you want? It comes with perl.

--
brian d foy <brian@stonehenge.com>
  • Comment on Re: Automatic stack tracebacks in warnings?

Replies are listed 'Best First'.
Re^2: Automatic stack tracebacks in warnings?
by ikegami (Patriarch) on Jul 05, 2005 at 18:09 UTC

    He wants to "find a way to get tracebacks to warnings, even those generated by the compiler", so replacing warns with clucks won't do.

      You don't have to replace every instance of warn() with cluck(). You just have to make perl call cluck() when it calls warn().

      The implementation of cluck() is simply

      package Carp; sub cluck { warn longmess @_ }

      Make your __WARN__ handler do that and you're all set.

      --
      brian d foy <brian@stonehenge.com>
Re^2: Automatic stack tracebacks in warnings?
by Tanktalus (Canon) on Jul 05, 2005 at 18:13 UTC

    No. What Carp::cluck does is warns with trace only when you call it. I'm trying to catch the ones that happen from inside the perl VM - such as "use of uninitialized" warnings. What I'd like to do is basically completely mask the warn built-in function with Carp::cluck (assuming that the perl VM calls warn, which is likely to be the case), but the best I can do now is fake it with the __WARN__ handler.

    That said, ikegami pointed me along the right path, and I now got this working.