Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: calling subroutines from variables

by injunjoel (Priest)
on Aug 21, 2008 at 18:44 UTC ( #705936=note: print w/ replies, xml ) Need Help??


in reply to calling subroutines from variables

Just a thought, though probably not the most secure...

#!/usr/bin/perl -w use strict; my @list_o_subs = ('one','two','three','one','two','one','three','two' +); { no strict 'refs'; for(@list_o_subs){ &{$_}; } } sub one { print "called sub 'one'\n"; } sub two { print "called sub 'two'\n"; } sub three { print "called sub 'three'\n"; }
Outputs
called sub 'one' called sub 'two' called sub 'three' called sub 'one' called sub 'two' called sub 'one' called sub 'three' called sub 'two'

Update!
I really should read more thoroughly before I post... This is basically what Bloodnok suggested.

-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo


Comment on Re: calling subroutines from variables
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://705936]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (17)
As of 2015-07-02 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls