jhanna has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to reference an object's method. The object is $o, the method is foo_edit. The trouble is foo is a value in $bar. $o->$bar."_edit"() fails. What's the correct ()'s and {}'s to make this work?
If i do my $b=$bar."_edit" and $o->$b() it works, but I don't wanna make temp vars like that.
{$o}->{$bar."_edit"}() fails (undefined &main::).
$o->{$bar."_edit"}() fails (undefined &main::).
$o->"${bar}_edit"() fails (syntax near ->"${c}_edit").
Who can enlighten me on this mystery?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: object ref syntax
by merlyn (Sage) on Feb 08, 2002 at 23:44 UTC | |
by jhanna (Scribe) on Feb 08, 2002 at 23:55 UTC | |
by bbfu (Curate) on Feb 09, 2002 at 01:43 UTC | |
by Anonymous Monk on Feb 10, 2002 at 01:31 UTC | |
|
Re: object ref syntax
by Anonymous Monk on Feb 09, 2002 at 01:08 UTC | |
by Anonymous Monk on Feb 09, 2002 at 05:19 UTC | |
|
Re: object ref syntax
by enoch (Chaplain) on Feb 09, 2002 at 17:14 UTC |