in reply to Re^2: Link methods to hash values
in thread Link methods to hash values
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. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Link methods to hash values
by Herkum (Parson) on Oct 01, 2006 at 20:53 UTC | |
by tinita (Parson) on Oct 02, 2006 at 08:03 UTC |