Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: how to use attributes?

by Moron (Curate)
on Mar 22, 2007 at 18:41 UTC ( [id://606092]=note: print w/replies, xml ) Need Help??


in reply to how to use attributes?

No, only the attributes listed in the documentation you reference are supported. E.g. "locked" is supported but "Constructor" isn't.

Correction: "Arbitrary" attributes need a handling subroutine (of the same name as the attribute) to be defined in your class. That facility also needs to be turned on using Attribute::Handlers. Your code will then only work on v5.6.0 of Perl onwards and so should therefore formally require that version (or a later one if otherwise appropriate). For example:

require v5.6.0; use Attribute::Handlers; package Whatever; #... sub Mutator : ATTR{CODE} { my ( $package, $symbol, $referent, $attr, $data ) = @_; # ... do whatever you want with mutators }
User-defined attributes can apply to other types, not just CODE as also explained in the documentation.

-M

Free your mind

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2024-04-26 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found