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).
Caution: Contents may have been coded under pressure.
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.
In Section
Seekers of Perl Wisdom