Perl :Getting the name of the current subroutine

Posted by kiruthika on Stack Overflow See other posts from Stack Overflow or by kiruthika
Published on 2010-04-01T10:49:22Z Indexed on 2010/04/01 10:53 UTC
Read the original article Hit count: 512

Filed under:

Hi all,

In perl we can get the name of the current package and current line number Using the predefined variables like _PACKAGE and __LINE .

Like this I want to get the name of the current subroutine.

Example

use strict;
use warnings;

print __PACKAGE__;
sub test()
{
    print __LINE__;
}
&test();

In the above code I want to get the name of the subroutine inside the function 'test'.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about perl