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');
In reply to Re: Calling a sub from a variable ?
by Thilosophy
in thread Calling a sub from a variable ?
by ZlR
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |