[Melbourne-pm] Caller depth

Rick Measham rick at measham.id.au
Tue Nov 22 18:12:51 PST 2005


I'm sure there must be a better way to do this, so I thought I'd ask.

At any given point in a program, I throw in a debug. I want these to 
look nice so I want to indent them depending on where they're called 
from. I'm doing this most successfully with the following code:

my $n = 1;
while( caller($n) ){ $n++ }

So at each level, we indent based on $n.

But that's totally mad (IMHO). Is there any known way to get the 'depth' 
of the caller without counting?

Cheers!
Rick Measham


-- 
  "War is God's way of teaching Americans geography."
                              -- Ambrose Bierce


More information about the Melbourne-pm mailing list