I'm not quite sure how to make these lvalues, but you can generate accessor/mutator methods without using eval. Here's a quick example:
foreach my $field (@required_fields) { no strict 'refs'; chomp $field; *$field = sub { my $self = shift; if ($_[0]) { $self->{$field} = $_[0]; } else { $self->{$field); } }; }
Note: I am not necessarily endorsing this type of hybrid mutator/accessor, just using it as an example.
In reply to Re: Automagic subroutines
by revdiablo
in thread Automagic subroutines
by rje
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |