http://www.perlmonks.org?node_id=1929

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

Can I get a subroutine's name from inside the subroutine?

Originally posted as a Categorized Question.

  • Comment on Can I get a subroutine's name from inside the subroutine?

Replies are listed 'Best First'.
Re: Can I get a subroutine's name from inside the subroutine?
by vroom (His Eminence) on Jan 10, 2000 at 10:04 UTC
    use the caller function:
    sub foo { my $this_subs_name = (caller(0))[3]; }