/ P e r l 6 \
Perl 5 Number String Bool
Impose context + ~ ?
Bitwise OR | +| ~| ?| Logic OR: ||, or
Bitwise AND & +& ~& ?& Logic AND: &&, and
Bitwise XOR ^ +^ ~^ ?^ Logic XOR: ^^, xor
Bitwise NOT ~ +^ ~^ ?^, ! Logic NOT: !, not
Bitshift left << +< ~<
Bitshift right >> +> ~>
####
Get a string, Get a list
Perl 5 $foo x 5 ($foo) x 5
Perl 6 $foo x 5 $foo xx 5
####
$foo = $bar if not defined $foo;
$foo = $baz if not defined $foo;
$foo = $quux if not defined $foo;
####
for zip(@foos, 0...) -> $foo, $i {
# Here, $foo is an element of @foo
# and $i is its index.
}
####
my @sums = @foo »+« @bar;
####
my @sums = map { $^a + $^b } zip(@foo, @bar);
####
if $foo eq 'bar' | 'baz' | 'quux' { ... }
if $foo eq any « bar baz quux » { ... } # Other style
####
if $foo eq 'bar' or $foo eq 'baz' or $foo eq 'quux' { ... }