Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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?
[Tanktalus]: Discipulus: I'd have tried my hand at it, but OP said something about not replying if you're experienced at regexes :)
[Tanktalus]: And now that I've been using regexes in C++, I'm thinking that might apply :)

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2017-12-18 23:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (501 votes). Check out past polls.

    Notices?