Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Switch/case as a jump table with C-style fall-through

by dragonchild (Archbishop)
on May 12, 2005 at 13:18 UTC ( #456376=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    switch (i) {
        0,1: foo();
        2: bar(); break;
        3: baz(); break;
    };
    
  2. or download this
    my $switch = Switch->new(
        [ '5', sub {} ], # Matches '005'
    ...
        [ sub { $foo->bar( @_ ) }, sub {} ] # coderef
        [ 1 .. 3, 8 .. 20, sub {} ] # Multiple cases
    );
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://456376]
help
Chatterbox?
[Discipulus]: choroba i made you Bishop !!
[choroba]: 9999 points until level 23 - Archbishop.
[LanX]: darn trying to downvote him again fails ... ;-P
[Discipulus]: congrats!
[LanX]: His Excelleny Choroba will now nbe clothed in his new robe ...
[Discipulus]: bishop ship sheeps in the shop..
[1nickt]: Discipulus too easy!
[1nickt]: "The sixth sheik's sixth sheep's sick" (if you are after 'sh' tongue twisters)
[Discipulus]: ok try it in Eatalian ;=)
[Eily]: Discipulus I don't suppose you can do the same for me can you ? :P

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2017-09-26 12:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (294 votes). Check out past polls.

    Notices?