Erm ... I meant MODIFY_CODE_ATTRIBUTES from Attribute::Handlers. Your MODIFY_CODE_ATTRIBUTES doesn't actually modify code attributes... Consider:

#!/usr/bin/perl use strict; use warnings; use Devel::Peek(); BEGIN { sub bar; print STDERR "\nDumping " . \&bar . " in BEGIN.\n"; Devel::Peek::Dump(\&bar); } use Attribute::Handlers; use attributes; sub Lion : ATTR { print "\ngroaarr!\n"; } sub bar : Lion method { print "pling.\n"; } print STDERR "\nDumping " . \&bar . " after attr assignment.\n"; Devel::Peek::Dump(\&bar);

Output:

Dumping CODE(0x97ad654) in BEGIN. SV = RV(0x97c32c0) at 0x97a3c40 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x97ad654 SV = PVCV(0x97aff40) at 0x97ad654 REFCNT = 2 FLAGS = () IV = 0 NV = 0 COMP_STASH = 0x976fb50 "main" ROOT = 0x0 XSUB = 0x0 XSUBANY = 0 GVGV::GV = 0x97b92ec "main" :: "bar" FILE = "attr2.pl" DEPTH = 0 FLAGS = 0x0 OUTSIDE_SEQ = 205 PADLIST = 0x97b92d4 PADNAME = 0x97936f0(0x0) PAD = 0x979366c(0x97781b0) OUTSIDE = 0x9770774 (UNIQUE) groaarr! Dumping CODE(0x97ad654) after attr assignment. SV = RV(0x97c3304) at 0x976fc28 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x97ad654 SV = PVCV(0x97aff40) at 0x97ad654 REFCNT = 2 FLAGS = (METHOD) IV = 0 NV = 0 COMP_STASH = 0x976fb50 "main" START = 0x97adc90 ===> 4079 ROOT = 0x97ac540 XSUB = 0x0 XSUBANY = 0 GVGV::GV = 0x97b92ec "main" :: "bar" FILE = "attr2.pl" DEPTH = 0 FLAGS = 0x40 OUTSIDE_SEQ = 333 PADLIST = 0x97df7e0 PADNAME = 0x97bffbc(0x9777fc0) PAD = 0x97df798(0x97e1150) OUTSIDE = 0x976fdf0 (MAIN)

Note the changed PVCV.


In reply to Re^5: Is there a way to access the name under which a subroutine was first defined? by shmem
in thread Is there a way to access the name under which a subroutine was first defined? by ELISHEVA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.