| |
| Recipe 2.13: Calling Methods Indirectly |
Last Updated: Sep 8, 2003
Status: Draft
|
|
|
|
How important is this problem to you?
(Login to Vote)
5.00 Rating, 3 Votes
|
|
How acceptable is the proposed solution?
(Login to Vote)
5.00 Rating, 2 Votes
|
|
Problem:
   
You want to call a method of an object or class, but the name of the method won't be known until runtime.
Solution:
   
Use indirect syntax, possibly with a check to CAN to be safe:
my $method = "foo";
$obj.$method if $obj.CAN.$method;
MyClass.$method if MyClass.CAN.$method;
Discussion:
Issue:
Any problems with $obj.$foo.$bar?
|
|