I second ikegami's comment: what is the purpose?
With Perl there are amazing things that you can discover about what is going on in a sub. Just some simple example code is shown below. I am unsure as to what you want.
#!/usr/bin/perl -w
use strict;
print "testing main\n";
x();
sub x
{
print "In sub x\n";
print " I am: ", WHOamI(), "\n";
SubLevel2();
}
sub SubLevel2
{
print "in sub SubLevel2\n";
print " I am: ", WHOamI(), "\n";
print " I was called by ", WHOwasI(),"\n";
}
sub WHOamI { (caller(1))[3] }; #returns name of the
#sub that called this sub
sub WHOwasI { (caller(2))[3] }; #returns name of the parent of
#the sub that called this sub
__END__
#prints
testing main
In sub x
I am: main::x
in sub SubLevel2
I am: main::SubLevel2
I was called by main::x
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|