Help for this page

Select Code to Download


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