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

GrandFather

can you explain me the following line. I am not able to understand what is that doing exactly.
my @var = map {$arr$_} grep {$_ & 1} 1..$#arr;

  • Comment on Re^2: Quicly extracting odd index elements in the array with grep

Replies are listed 'Best First'.
Re^3: Quicly extracting odd index elements in the array with grep
by ikegami (Patriarch) on Aug 10, 2006 at 05:51 UTC
    Read the comments from the bottom up.
    my @var = # Store the elements in @var. map { $arr[$_] } # Get the elements at the remaining indexes. grep { $_ & 1 } # Filter out the even indexes. 0..$#arr; # Create a list of @arr's indexes.