|Keep It Simple, Stupid|
Subroutine Call Stack - For Entire Programby Anonymous Monk
|on Aug 13, 2009 at 21:54 UTC||Need Help??|
Anonymous Monk has asked for the
wisdom of the Perl Monks concerning the following question:
My objective is to find out "what subroutine called what subroutine" & accomplish this for the *entire* perl program. To clarify this objective: for each subroutine, I am trying to find the parent & do this for every subroutine that exists. This would allow me to get a subroutine stack of my entire program. My program - including my own modules - is ~ 10,000 lines. The number of subroutines is ~ 100 (one hundred).
I am aware of the "caller" function, which provides access to the call stack. Furthermore, in order to find out who the "parent" is, something like this can be used: $parent = ( caller(1) )3
However, the above requires inserting the aforementioned code snippet into each & every subroutine (in order to achieve the objective).
Question: is there an easy way to obtain my objective without inserting the caller function all over my code? Is there an easier alternative?
Thanks in advance for any help.