Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I would like to know whether there is any perl variable that hold the method name inside a method .
for Example :
sub method1 {
$name =
}

I need $name = method1
Thanks,
-John

Replies are listed 'Best First'.
Re: perl varible that holds method name
by ikegami (Patriarch) on Sep 16, 2009 at 21:09 UTC
    This information can be accessed via caller
    sub method1 { my $name = (caller(0))[3]; print("$name\n"); } method1(); # main::method1 *method2 = \&method1; method2(); # main::method1 also
      Thanks.
Re: perl variable that holds method name
by moritz (Cardinal) on Sep 16, 2009 at 21:09 UTC
    This information is available from caller.
    Perl 6 - links to (nearly) everything that is Perl 6.