Do any of you know of a way for a function to get at the name it was actually called by in the code as opposed to the name of the original function definition?
Short answer - you can't :-) Coderefs have a pointer back to the glob (if any) that defined them. So only one name.
If it were me, I'd probably use closures... something like:
sub make_sub { my $name = shift; return sub { print "My name is $name\n" }; }; *sub1 = make_sub( 'sub1' ); *sub2 = make_sub( 'sub2' ); *sub3 = make_sub( 'sub3' );
In reply to Re: How to get the name of an aliased function
by adrianh
in thread How to get the name of an aliased function
by DrWhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |