Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

(jeffa) Re: dispatch table of functions and arguments

by jeffa (Chancellor)
on Sep 03, 2002 at 13:31 UTC ( #194761=note: print w/ replies, xml ) Need Help??


in reply to dispatch table of functions and arguments

fglock has you covered ... here is some more code that illustrates how to pull the pieces out and use them:

use strict; my %dispatch = ( foo => [\&foo,qw(5 * 4)], bar => [\&bar,'HELLO'], ); for (keys %dispatch) { my ($sub,@args) = @{$dispatch{$_}}; print $sub->(@args),"\n"; } sub foo { my ($n1,$op,$n2) = @_; return eval "$n1 $op $n2"; } sub bar { return ucfirst lc shift; }

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)


Comment on (jeffa) Re: dispatch table of functions and arguments
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-10-02 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (56 votes), past polls