in reply to Re^2: How to map function name to coderef?
in thread How to map function name to coderef?
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
True laziness is hard work
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: How to map function name to coderef?
by ikegami (Patriarch) on Jan 07, 2012 at 00:37 UTC | |
by Anonymous Monk on Jan 07, 2012 at 01:30 UTC | |
by ikegami (Patriarch) on Jan 07, 2012 at 02:49 UTC |
In Section
Seekers of Perl Wisdom