Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by Anonymous Monk
on Jan 10, 2000 at 09:13 UTC ( [id://1929]=perlquestion: print w/replies, xml ) Need Help??

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.

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]; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1929]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-19 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found