If I understand you right, the typical idiom to deal with the situation you describe is something like (untested):
...which does not require the methods to know their names.package Foo; # ... my @fields = qw( eenie meenie minie moe ); make_accessor( $_ ) for @fields; # ... sub make_accessor { my $method = shift; my $sub = sub { # your accessor here; }; my $class = caller; { no strict 'refs'; *{ "$class\::$method" } = $sub; } return; }
the lowliest monk
In reply to Re^3: How to get the name of an aliased function
by tlm
in thread How to get the name of an aliased function
by DrWhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |