in reply to Invoke object methods with a symbolic reference
I don't quite get the compactness of $a->${$a->{f}}('foobar'); but maybe what you are loking for is to store a reference to the foo method instead of its name:
sub new { return bless {f => \&foo}, $_[0]; } # \&foo is a reference to foo()And then you can call the subroutine (including under use strict) as $a->{f}('foobar'); just note that in this case foo is just a regular function, not a method any more and you either have to remove the shift in the function or pass it $a.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Rea: Invoke object methods with a symbolic reference
by baku (Scribe) on Feb 14, 2001 at 19:59 UTC |