Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by vroom (Pope)
on Jan 10, 2000 at 10:04 UTC ( #1932=categorized answer: print w/replies, xml ) Need Help??

Q&A > subroutines > Can I get a subroutine's name from inside the subroutine? - Answer contributed by vroom

use the caller function:
sub foo { my $this_subs_name = (caller(0))[3]; }

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-11-21 09:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (297 votes). Check out past polls.

    Notices?