![]() |
|
Think about Loose Coupling | |
PerlMonks |
Getting the size of the call stack (efficiently)by DrWhy (Chaplain) |
on Feb 27, 2007 at 18:15 UTC ( [id://602360]=perlquestion: print w/replies, xml ) | Need Help?? |
DrWhy has asked for the wisdom of the Perl Monks concerning the following question:
The discussion started at Getting size of call stack describes a straightforward way to get the current call stack size:
(That's my own implementation of the algorithm.) This is a pretty inefficent way to get the stack depth. For implementations where this is only needed once, e.g. as part of generating a die message, that's not much of an issue. I have a tracing module that produces lots of debugging output, and I'd like to add an indication of the stack depth to each line of debug output -- that would lead to alot of repetition of this loop. Does anyone know of a more efficient method for finding just the stack depth without using multiple calls to caller() each time you need that number? --DrWhy "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."
Back to
Seekers of Perl Wisdom
|
|