I wrote:

Is there a way to get the name of the current sub?

So:

sub test_sub {
    $subname = ???;
    print $subname; # prints test_sub?
}


Sorry, just found it:
http://www.unix.org.ua/orelly/perl/cookbook/ch10_05.htm

sub test_sub {
    $subname = (caller(0))[3];
    print $subname; # prints test_sub
}

Cheers,
Nigel

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to