Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 goofing around in the Monastery: (2)
As of 2024-05-26 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found