[Melbourne-pm] Caller depth

leif.eriksen@hpa.com.au leif.eriksen at hpa.com.au
Tue Nov 22 19:37:30 PST 2005


One extra thing - the call stack you get from repeatedly walking up
caller() may not be the real call trace !

>From perldoc -f goto

The "goto-&NAME" form is quite different from the other forms
of "goto".  In fact, it isn't a goto in the normal sense at
all, and doesn't have the stigma associated with other gotos.
Instead, it exits the current subroutine (losing any changes
set by local()) and immediately calls in its place the named
subroutine using the current value of @_.  This is used by
"AUTOLOAD" subroutines that wish to load another subroutine 
And then pretend that the other subroutine had been called in the
first place (except that any modifications to @_ in the current
subroutine are propagated to the other subroutine.)  

>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
After the "goto", not even "caller"
will be able to tell that this routine was called first.
>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

L

-----Original Message-----
From: rick at measham.id.au [mailto:rick at measham.id.au] 
Sent: Wednesday, 23 November 2005 1:13 PM
To: melbourne-pm at mail.pm.org
Subject: [Melbourne-pm] Caller depth


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
_______________________________________________
Melbourne-pm mailing list
Melbourne-pm at pm.org
http://mail.pm.org/mailman/listinfo/melbourne-pm
**********************************************************************
IMPORTANT
The contents of this e-mail and its attachments are confidential and intended
solely for the use of the individual or entity to whom they are addressed.  If
you received this e-mail in error, please notify the HPA Postmaster, postmaster at hpa.com.au,
then delete  the e-mail.
This footnote also confirms that this e-mail message has been swept for the
presence of computer viruses by Ironport. Before opening or using any
attachments, check them for viruses and defects.
Our liability is limited to resupplying any affected attachments.
HPA collects personal information to provide and market our services. For more
information about use, disclosure and access see our Privacy Policy at
www.hpa.com.au
**********************************************************************


More information about the Melbourne-pm mailing list