switch (i) { 0,1: foo(); 2: bar(); break; 3: baz(); break; }; #### my $switch = Switch->new( [ '5', sub {} ], # Matches '005' [ '--string-match', '6', sub {} ], # Doesn't match '006', [ qr/floober/, sub {} ] # regex match [ sub { $foo->bar( @_ ) }, sub {} ] # coderef [ 1 .. 3, 8 .. 20, sub {} ] # Multiple cases );