Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Oh ye who hold all Perl wisdom!
My Perl foo is sufficient to understand the following:
#!/bin/env perl use strict; use warnings; my $coderef = \&f; print &$coderef, $/; sub f { return 1; }
...which simply outputs upon execution:
1
Yet, what I would really like is to map a string to the code reference of the function itself -- something similar to the following (syntax is incorrect...):
my $s = 'f'; print $s(), $/;
...which would give similar output as the preceding code.
Those that bear all ye knowledge, what is the syntactic incantation?
Thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to map function name to coderef?
by eyepopslikeamosquito (Archbishop) on Jan 07, 2012 at 02:29 UTC | |
Re: How to map function name to coderef?
by choroba (Cardinal) on Jan 07, 2012 at 00:04 UTC | |
by Anonymous Monk on Jan 07, 2012 at 00:15 UTC | |
by ikegami (Patriarch) on Jan 07, 2012 at 00:39 UTC | |
by GrandFather (Saint) on Jan 07, 2012 at 00:36 UTC | |
by ikegami (Patriarch) on Jan 07, 2012 at 00:37 UTC | |
by Anonymous Monk on Jan 07, 2012 at 01:30 UTC | |
| |
Re: How to map function name to coderef?
by AnomalousMonk (Archbishop) on Jan 07, 2012 at 00:59 UTC | |
Re: How to map function name to coderef?
by bluescreen (Friar) on Jan 07, 2012 at 00:30 UTC | |
Re: How to map function name to coderef?
by TJPride (Pilgrim) on Jan 07, 2012 at 03:55 UTC | |
by GrandFather (Saint) on Jan 07, 2012 at 05:50 UTC | |
by TJPride (Pilgrim) on Jan 07, 2012 at 08:12 UTC | |
by GrandFather (Saint) on Jan 07, 2012 at 21:40 UTC | |
|
Back to
Seekers of Perl Wisdom