Problems? Is your data what you think it is? | |
PerlMonks |
Re^2: Is there a way to access the name under which a subroutine was first defined?by ELISHEVA (Prior) |
on Feb 16, 2009 at 10:05 UTC ( [id://744017]=note: print w/replies, xml ) | Need Help?? |
By "initially" I meant the name "foo" assigned by sub foo {...} rather than any aliases assigned at a later point. But as you point out, it definitely does seems to be a "when" issue. My new toy Devel::Peek::Dump(...) also reports the subroutine name correctly if it is called after the sub is compiled, but not when the subroutine's attributes are being processed via MODIFY_CODE_ATTRIBUTES (during the compilation of the subroutine definition). This is illustrated by the following small script:
which reports GVGV:GV = 0x0 when called within the MODIFY_CODE_ATTRIBUTES method but GVGV::GV = 0x819ba28 "main" :: "bar" when called after bar(...) is compiled, as the captured output below shows:
Best, beth Update: replaced original example with script illustrating different outputs from within MODIFY_CODE_ATTRIBUTES and after compilation; added explanation of what I meant by "initially".
In Section
Seekers of Perl Wisdom
|
|