You can use can to return a coderef:
use strict; use warnings; my $doFoo = main->can ('foo'); print $doFoo ? $doFoo->() : "Can't foo\n"; sub foo { return 1; }
Prints:
1
In reply to Re^3: How to map function name to coderef?
by GrandFather
in thread How to map function name to coderef?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |