Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: When should I use a dispatch table?

by jdporter (Canon)
on Dec 01, 2006 at 18:07 UTC ( #587246=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %real_functions = (
      wipe_system => sub { system "rm -rf /" },
    ...
        : \%real_functions;
    
    $funcs->{'wipe_system'}->();
    
  2. or download this
    {
        package SystemFunctions::Real;
    ...
        : 'SystemFunctions::Debug';
    
    $funcs->wipe_system();
    
  3. or download this
    my %dispatch = (
      incr => sub { $x++ },
      decr => sub { $x-- },
    );
    $dispatch{$op}->();
    
  4. or download this
    sub incr { shift; $x++ }
    sub decr { shift; $x-- }
    
    main->$op();
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-10-31 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (225 votes), past polls