kstar has asked for the wisdom of the Perl Monks concerning the following question:
The following not only does not work, it confuses the parser:my $obj = MyObject->new; my $meth = 'dosomething'; $obj->meth;
This is a workaround I've found:my $obj = MyObject->new; my %meth = (a => 'dosomething'); $obj->$meth{a};
I am quite surprised by this. Can anyone explain to me what is happening here? Much appreciated. - Kurtmy $obj = MyObject->new; my %meth = (a => 'dosomething'); $obj->{ $meth{a} };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Surprising quirk of method call parser
by kcott (Archbishop) on Nov 04, 2010 at 16:11 UTC | |
by kstar (Novice) on Nov 04, 2010 at 17:41 UTC | |
|
Re: Surprising quirk of method call parser
by talexb (Chancellor) on Nov 04, 2010 at 15:47 UTC | |
by kstar (Novice) on Nov 04, 2010 at 17:28 UTC |