sguazt has asked for the wisdom of the Perl Monks concerning the following question:
If you have this perl code:
package Foo; use strict; sub new { return bless {f => 'foo'}, $_[0]; } sub foo { shift; print "@_\n"; } 1; package main; use strict; my $a = new Foo(); my $f = $a->{f}; no strict qw(subs); $a->$f('foobar'); 1; __END__
I would like invoke 'foo' method in a more compress form, such as:
$a->${$a->{f}}('foobar');
but this latter form doesn't work!!
Any idea???
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Invoke object methods with a symbolic reference
by mirod (Canon) on Feb 14, 2001 at 18:13 UTC | |
by baku (Scribe) on Feb 14, 2001 at 19:59 UTC | |
|
Re: Invoke object methods with a symbolic reference
by merlyn (Sage) on Feb 14, 2001 at 19:51 UTC |