Here's the only real problem:
sub xmlrpc :ATTR(CODE) {}
This says "for the attribute xmlrpc, do nothing". The code attached to the ATTR(CODE) is to be run at the time the code with that attribute is compiled. You have an empty block, so Perl does that: nothing at all.

The toughest part about using Attribute::Handlers is remembering that the attribute code gets control at compile time, and that the only way to influence execution later is to record information at that point.

Note that friedo's code is recording information in a hash in the sub xmlrpc: ATTR(CODE) subroutine, and the xmlrpc_methods sub then just reads it off. If you look at Class::AutoPlug::Plugin, you can see an example of using a similar mechanism to "advertise" methods and method hooks.

[I just noticed a documentation bug I have to fix there - the hooks actually get and send back a Class::AutoPlug::ResultState, instead of magical numeric values, wich allows the hooks to manipulate @_ and to replace the real return value for a method. However, this is unrelated to the attribute-based "advertising"; check out the source for the details on how that works. I'll be pushing another version with the doc corrections this evening.]


In reply to Re^3: Trying to figure out subroutine attributes by pemungkah
in thread Trying to figure out subroutine attributes by Anonymous Monk

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.