gmpassos has asked for the wisdom of the Perl Monks concerning the following question:
What I want is to have a subrotine &test1, than make a reference to it at &test2, and when I call test1 or test2 know what name I'm using to call them.
I have tried caller(0), that return some extra values, including the subroutine name, but always the real/first name.
To understand better see this code:
The output is:sub test1 { my ($package, $filename, $line, $subroutine, @rest) = caller(0) ; print "<$subroutine> @_\n" ; } *test2 = \&test1 ; &test1(123) ; &test2(456) ;
Soo, you can see that calling from &test1 or &test2 $subroutine is always 'main::test1'!<main::test1> 123 <main::test1> 456
Note that I can't change the behavior or the way that I call &test1 or &test2.
Graciliano M. P.
"Creativity is the expression of the liberty".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting the name of the subroutine called. There is a way for a clone references?!
by liz (Monsignor) on Sep 08, 2003 at 08:28 UTC | |
|
Re: Getting the name of the subroutine called. There is a way for a clone references?!
by chromatic (Archbishop) on Sep 08, 2003 at 06:12 UTC | |
|
Re: Getting the name of the subroutine called. There is a way for a clone references?!
by Anonymous Monk on Sep 08, 2003 at 06:38 UTC | |
|
Re: Getting the name of the subroutine called. There is a way for a clone references?!
by leriksen (Curate) on Sep 08, 2003 at 07:09 UTC |