##
for my $method (qw/ field1 field2 field3 /) {
no strict 'refs';
*$method = sub {
use strict 'refs';
my $self = shift;
if (@_) {$self->{$method} = shift};
return $self->{$method};
};
}
##
##
for my $method (qw/ ... /) {
my $sub = sub { the code ... };
no strict 'refs';
*$method = $sub;
}