Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Class::Accessor and Damian's PBP

by Roy Johnson (Monsignor)
on Feb 23, 2006 at 19:54 UTC ( [id://532380]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Class::Accessor and Damian's PBP
in thread Class::Accessor and Damian's PBP

After playing around in several directions, I realized that it's trivially easy to generate default accessors, which may be why there are so many modules for it (although it makes me wonder why there are any).
for my $property (qw(several members defined public)) { no strict 'refs'; *{"get_$property"} = sub { (shift)->{$property} }; *{"set_$property"} = sub { (shift)->{$property} = $_[0] }; }

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^4: Class::Accessor and Damian's PBP
by cbrandtbuffalo (Deacon) on Feb 23, 2006 at 21:24 UTC
    You got it. I took at look and that's almost exactly what Class::Accessor does.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-20 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found