Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How to map function name to coderef?

by bluescreen (Friar)
on Jan 07, 2012 at 00:30 UTC ( #946687=note: print w/replies, xml ) Need Help??


in reply to How to map function name to coderef?

you can do it using eval to return the coderef, as follows:

use strict; use warnings; sub some_sub { "hello\n"; } my $sub_name = 'some_sub'; my $coderef = eval("\\&$sub_name"); print &$coderef();

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946687]
help
Chatterbox?
and the sunlight beams...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2017-04-25 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (453 votes). Check out past polls.