use v6;
my $bool1 = 1;
my $bool2 = 0;
given ($bool1, $bool2) {
when (0, 0) {say "0, 0"}
when (0, 1) {say "0, 1"}
when (1, 0) {say "1, 0"}
when (1, 1) {say "1, 1"}
}
given ("15", "example", "3.14") {
say $_.WHAT;
when ($, $, Str) { say "I got a String of $_[2]" }
}
given (4, 5) {
when ( $, $) {say "Ok"}
}
given ("fly.mp3", 34, "It's funny") {
when (/.mp3$/, /4$/, *.chars > 4) {say "Perfact"}
}
given 5 {
when 1..10 {say "1..10 contains 5"}
}
given 42 {
when Int {
say "Int";
succeed "Found";
say "Never this";
}
when 42 {say 42}
default {say "duno"}
}
my $ticks = 0;
given $ticks {
when 1 {say ""; }
when 1/2 {say "/"; }
when Int {say $_.Str; }
when Rat {say $_.perl; }
die "Duration must be Int or Rat, but it's { $_.WHAT }";
}
my $boring-lines = 0;
for $*IN.lines {
when /"Lunasa" | "Altan"/ { say "Found band!"; }
when /"fiddle" | "flute"/ { say "Found instrument!"; }
$boring-lines++;
}