renodino has asked for the wisdom of the Perl Monks concerning the following question:
I'd havemy $foo : shared = 'foo';
Note I'm trying to avoid the fully qualified syntax, i.e.,my $foo : Sociable = 'foo';
Which presumably means I need to install my attribute handlers into the UNIVERSAL space. Which does seem to work OK.my Thread::Sociable $foo : Sociable = 'foo';
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:
and then calling the &$old_XXX_attr() with appropriate args after my SociableXXX() is done pulling out the attributes its interested in.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;
Am I way off base ? Is there a better way ? Any pointers (esp. to any code examples that do the same) much appreciated!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Attribute confusion
by friedo (Prior) on Oct 19, 2006 at 20:56 UTC | |
|
Re: Attribute confusion
by chromatic (Archbishop) on Oct 19, 2006 at 21:10 UTC | |
by renodino (Curate) on Oct 19, 2006 at 22:24 UTC | |
by chromatic (Archbishop) on Oct 20, 2006 at 09:30 UTC |