Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: dispatch table of functions and arguments

by fglock (Vicar)
on Sep 03, 2002 at 13:16 UTC ( #194757=note: print w/ replies, xml ) Need Help??


in reply to dispatch table of functions and arguments

%func = { Click => { func => \&compute, param => [ @param ] }, Click2 => { func => \&compute2, param => [ @param2 ] }, };
----------

update: How to set a parameter:

$func{Click2}{param} = [ 1, 2, "hello" ];

How to call a function:

&{ $func{Click2}{func} } ( @{$func{Click2}{param}} );

update: corrected @{} in func call

----------

There are many more ways to do it.

Also:

... Click => { func => \&compute, param => \@param }, ...

Or:

... Click => [ \&compute, \@param ], ...


Comment on Re: dispatch table of functions and arguments
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (15)
As of 2015-07-01 17:54 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 (15 votes), past polls