in reply to oo code ref
I think perhaps this is what you are a looking for:
You can also do this:my $meth = 'myFunction'; $obj->$meth(@args);
In general I would avoid goto since it is hard to get the dispatching right and you have to fiddle with @_ all of which will make your code that much harder to understand.my $meth = $obj->can('myFunction'); $obj->$meth(@args);
If you actually want a code reference to the method so that you can call it later on and have everything Just Work, then you want to use a closure like this:
Then later on you can just do:my $meth = sub { $obj->myFunction(@_) };
And you dont have to worry about making sure $self is properly on @_ etc etc.$meth->(@args);
|
|---|