in reply to Dynamically calling different functions?
The reason to do that is that if $meth has the name of a method, then $obj->$meth(@args) will dynamically look up the method on the fly.
You don't actually have to be using OO to do that, you can just use the fact that Perl's facilities for OO support don't tell functions and methods apart very well. The following bad hack should work just fine (albeit fairly slowly) for normal functions:
use Carp; # time passes... sub get_func { my $func_name = shift; my $pack = caller(); UNIVERSAL::can($pack, $func_name) || croak("Function '$func_name' not found in package '$pack'"); } # elsewhere what you wanted above becomes $register = get_func($command)->($register, $param);
|
|---|