I've released Carp::Source. It exports a function, source_cluck(), that does pretty much the same as Carp's cluck() except it also displays the source code context of all call frames, with three lines before and after each call being shown, and the call being highlighted. Enjoy.
In general I find that I don’t want to decide at the time of writing the code whether a particular instance of croak
will dump a stack trace or not. All I can decide is whether to throw an exception or warning in the current context or that of the caller, depending on what makes more sense. Whether to get stack traces or not is something I can only decide when I’m running the code: while investigating a problem, I often want to turn them on globally.
So I love Carp::Always, which makes all warn
s and die
s display a stack trace when it’s enabled. How about making Carp::Source work like that instead of the current “explicit authoring-time request” interface?
Re:Not very useful to me in this form
Aristotle on 2007-11-11T00:05:53