in reply to Re: Quicly extracting odd index elements in the array with grep
in thread Quicly extracting odd index elements in the array with grep

Here are some more efficient variants, if dealing with long lists. The first uses only half as much memory (and is probably faster), and the second uses no extra memory (and is probably the fastestand is still quite fast). The difference should be inconsequential for short lists.

my @var = map { $arr[$_*2+1] } 0..int(@arr/2)-1;
my @var; push(@var, $arr[$_*2+1]) for 0..int(@arr/2)-1;

Update: For speed considerations when dealing with long lists, refer to GrandFather's post.