Filter

my @a = 1..6;
my @even = grep * %% 2, @a;

Alternatively:

my @a = 1..6;
my @even = @a.grep(* %% 2);

Destructive:

my @a = 1..6;
@a .= grep(* %% 2);

Last updated