Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Modules for autogenerating accessor/mutator methods

by wolv (Pilgrim)
on Jun 05, 2005 at 13:10 UTC ( [id://463713]=note: print w/replies, xml ) Need Help??


in reply to Modules for autogenerating accessor/mutator methods

Attribute::Property is very elegant and simple. I like it mainly because it adds so little typing, instead using Perl's attributes to make any sub a property (accessor).
package Automobile; sub new : New; sub colour : Property; sub owner : Property { /^(?:Jack|Jill|Bob)$/ } package main; my $car = Automobile->new(colour => "red"); print $car->colour; # red $car->colour = "blue"; print $car->colour; # blue my $other_car = Automobile->new(owner => "Jack"); # works my $another_car = Automobile->new(owner => "Dad"); # fails

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2025-06-19 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.