http://www.perlmonks.org?node_id=929767

menth0l has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

How can i get function name and/or it's path inside :CODE attribute's body? In Perl 5.12 im using approach like in the example below. My problem is that when ported to Perl 5.10 i get wrong function name.
package MyAttributes; use Attribute::Handlers; sub UNIVERSAL::FOO : ATTR(CODE) { my ($package, $symbol, $referent, $attr, $data) = @_; # in 5.12 i get "*Baz::bar" # in 5.10 i get "*MyAttributes::ANON" my $f = *$symbol; $f =~ tr/*//d; print "Function $f is has FOO attribute"; } package Baz; sub bar :FOO { ... } 1;
What's the proper way to do it (i'd like it to be portable between 5.10 and 5.12)?