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

Re^2: switch statement

by davido (Archbishop)
on Sep 20, 2013 at 05:35 UTC ( #1054959=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @dispatch = (
      [ sub { shift =~ m/test/ } => sub { action } ],
    ...
        last;
      }
    }
    
  2. or download this
    my @dispatch = (
      ... same as above ...
    ...
    $dispatch[                                    # In the table...
      firstidx { $_->[0]($test_value) } @dispatch # do a lookup...
    ]->[1]();                                     # and take action.
    
  3. or download this
    my @dispatch = (
      ...same as above ...
    );
    ( first { $_->[0]($test_value) } @dispatch )->[1]();
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054959]
help
Chatterbox?
beech waves a white flag -- no detectible causes of itch

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2016-12-09 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.