SPUG: Choosing an object's method at runtime
Aryeh "Cody" Sherr
asherr at cs.unm.edu
Wed May 24 11:52:39 CDT 2000
man perlsub is what you are looking for
()s are only optional if the function is predeclared
essentially, $foo->$func looks like a reference to a scalar. I *think*
&$foo->$method should work (but pass $method your @_ array!), as well as
$foo->$method(); These both make it unambiguous.
hope this helps.
cody
On Tue, 23 May 2000, Sanford Morton wrote:
>I'm feeling particularly dense today. I want to choose an object's
>method at run time:
> $object = new Some_Class;
> $method = 'stop';
>But then
> $object->$method;
>gets a syntax error, whereas
> $object->$method();
>seems not to.
>
>Does anyone know which man page covers this? I'm clueless. I need more
>sleep. --Sandy
>
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
> For Subscriptions, Email to majordomo at pm.org: ACTION spug-list EMAIL
> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address
>
>
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
For Subscriptions, Email to majordomo at pm.org: ACTION spug-list EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email address
More information about the spug-list
mailing list