in reply to Calling a sub from a variable ?

If by "hash solution" you mean that you want to build a hash full of function pointers that sounds like a good plan to me.
my %coderefs = ( foo => \&Module::function_foo, ); my $function = 'foo'; my $coderef = $coderefs{$function}; unless ($coderef){ # do something about the missing function # (for example try to load it from the module # and augment the %coderefs, this would eliminate # the need to manually set up %coderefs in advance) } my $result = $coderef->('some parameters');

Replies are listed 'Best First'.
Re^2: Calling a sub from a variable ?
by ZlR (Chaplain) on Mar 22, 2005 at 11:35 UTC
    Thanks Thilosophy !

    The

    foo => \&Module::function_foo
    part was what i was missing !

    This sounds exactly like what i had in mind, i'll give it a try !

    zlr