[CMI.PM] get function name?

Daniel S. Lewart lewart at uiuc.edu
Thu Apr 21 09:01:17 PDT 2005


Jay,

>   Anyone know if there is a way to get the current function name?  For
>   example:

Yes; see (the suboptimally documented) caller function:
	http://perldoc.perl.org/functions/caller.html

> sub myFunc
> {
> 	my( $f ) = ?????;
> 	# want $f equal to "MyFunc" or "myPkg::myFunc"
> }
> 1;

my $f = (caller(0))[3];		# myPkg::myFunc

Cheers,
Dan
http://cmi.pm.org/


More information about the Champaign-Urbana mailing list