[Tallahassee-pm] Subroutine Reference

Ryan Carmelo Briones mexnix at craonline.org
Wed Jan 21 09:57:15 CST 2004


---------- Original Message ----------------------------------
From: Ed Mansouri <emansouri at ucompass.com>
Date:  Wed, 21 Jan 2004 10:31:40 -0500 (EST)

>Hello,
>
>Is there a built-in variable that will recognize the name of a subroutine
>currently being executed?
>
>In other words:
>
>mySub();
>
>sub mySub {
>
>print ${some_symbol};
>
># and ${some_symbol} will return "mySub"
>
>}
>
>does anyone know what 'some_symbol' would be to make this possible?
>
>Ed

Check out caller():
http://www.perldoc.com/perl5.8.0/pod/func/caller.html

CODE:
use Data::Dumper;
call_sub();

sub call_sub() {
    print Dumper( caller(0) );
}



More information about the Tallahassee-pm mailing list