I'm trying to setup attributes for a module that emulates the behavior of threads::shared. So instead of
my $foo : shared = 'foo';
I'd have
my $foo : Sociable = 'foo';
Note I'm trying to avoid the fully qualified syntax, i.e.,
my Thread::Sociable $foo : Sociable = 'foo';
Which presumably means I need to install my attribute handlers into the UNIVERSAL space. Which does seem to work OK.

I've tried using Attributes::Handler, but with marginal success...things behave very badly when run under the debugger.

My concern is that my solution is tromping all over other attributes apps. At present, I'm using the following bit of code to init the handlers:

our $old_scalar_attr = \&UNIVERSAL::MODIFY_SCALAR_ATTRIBUTES; our $old_array_attr = \&UNIVERSAL::MODIFY_ARRAY_ATTRIBUTES; our $old_hash_attr = \&UNIVERSAL::MODIFY_HASH_ATTRIBUTES; *UNIVERSAL::MODIFY_SCALAR_ATTRIBUTES = \&SociableScalar; *UNIVERSAL::MODIFY_ARRAY_ATTRIBUTES = \&SociableArray; *UNIVERSAL::MODIFY_HASH_ATTRIBUTES = \&SociableHash;
and then calling the &$old_XXX_attr() with appropriate args after my SociableXXX() is done pulling out the attributes its interested in.

Am I way off base ? Is there a better way ? Any pointers (esp. to any code examples that do the same) much appreciated!


In reply to Attribute confusion by renodino

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.