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."