{ my $continue = 1; sub given ($$) { local $_ = shift; my $next = shift; my ($cond, $then); while ($next) { ($cond, $then, $next) = @$next; $then->() if $cond->() and $then; $continue or last; } } sub when (&$) { [$_[0], @{$_[1]}] } sub then (&;$) { [@_] } sub default(&) { [@_] } sub done() { $continue = 0 } sub isit ($$) { my @args=@_; [sub { $_ eq $args[0] }, @{$args[1]}] } } given 'baz', isit 'baz', then { print "String match!\n" } when {/z/} then { print "Hi!\n" } when {/o/} then { print "Oh!\n"; done } default { print "This is the default\n" } ;