If you don't want to use something like Class::MethodMaker, it's pretty trivial to do this sort of thing yourself.
package Foo; use strict; use warnings; foreach my $name(qw(foo bar baz quux narf)) { no strict 'refs'; *{ 'Foo::get_' . $name } = sub { my $self = shift; return $self->{$name}; }; }
Constructing the equivelent set_* methods is left as an exercise for the reader. :)
In reply to Re^3: Link methods to hash values
by friedo
in thread Link methods to hash values
by Herkum
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |