Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How Are Attributes Useful?

by pemungkah (Priest)
on Mar 24, 2007 at 08:40 UTC ( [id://606396]=note: print w/replies, xml ) Need Help??


in reply to How Are Attributes Useful?

Take a look at Class::AutoPlug. It uses attributes to allow you to declaratively build pluggable versions of non-pluggable modules using attributes and some clever uses of import(). Essentially, your pluggable main class looks like
package Something::Pluggable; use base qw(Class::Autoplug::Pluggable); 1;
and your plugins look like
package Something::Plugin::Foo; use base qw(Class::AutoPlug::Plugin); sub x:PluggedMethod(methodName) { ...} sub y:Prehook(someBaseMethod) { ... } sub z:Posthook(someBaseMethod) { ... } 1;
All the monkey code to find the methods, add hooks, etc., is handled inside the base classes, letting you concentrate on the actual job at hand. Attributes make it easy to define what you want declaratively, without stuff like having to construct lists of methods and hooks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://606396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2026-01-20 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (125 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.