Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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();


Comment on Re: How to map function name to coderef?
Download Code

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 web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-12-19 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (70 votes), past polls