Help for this page

Select Code to Download


  1. or download this
    my @a = map { transformation($_) } @b;
    # same as
    my @a;
    push @a, tranformation($_) for @b;
    @a
    
  2. or download this
    my @a = grep { condition($_) } @b;
    # same as
    ...
       push @b, $_ if condition($_);
    }
    @a
    
  3. or download this
    my @even = grep $_ % 2 == 0, @numbers;
    my @odd  = map $_ * 2 +1,    @numbers;
    
  4. or download this
    my @numbers = grep /^[0-9]+$/, @words;