Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Getting function name

by hotshot (Prior)
on Dec 31, 2002 at 12:12 UTC ( [id://223299]=perlquestion: print w/replies, xml ) Need Help??

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

Hi guys !

Is there a way to know the name of the function my program is currently in. for example:
sub testFunc { ... print &getFuncName(); # somehow will print 'testFunc' ... }
Just don't ask why I nedd that :-) Thanks

Hotshot

Replies are listed 'Best First'.
Re: Getting function name
by shotgunefx (Parson) on Dec 31, 2002 at 12:17 UTC
    See caller

    -Lee

    "To be civilized is to deny one's nature."
      And an application of caller() might look like this
      sub testFunc { print &getFuncName(); } sub getFuncName { return (caller(1))[3]; } testFunc(); __output__ main::testFunc

      HTH

      _________
      broquaint

        ++, was pressed for time.

        -Lee

        "To be civilized is to deny one's nature."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found