in reply to Quicly extracting odd index elements in the array with grep
grep and map:
use warnings; use strict; my @arr = (0,3,4,5,8,10,12,15); # # # # my @var = map {$arr[$_]} grep {$_ & 1} 1..$#arr; print "@var";
Prints:
3 5 10 15
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Quicly extracting odd index elements in the array with grep
by ikegami (Patriarch) on Aug 10, 2006 at 04:53 UTC | |
|
Re^2: Quicly extracting odd index elements in the array with grep
by bobf (Monsignor) on Aug 10, 2006 at 04:56 UTC | |
|
Re^2: Quicly extracting odd index elements in the array with grep
by Anonymous Monk on Aug 10, 2006 at 05:41 UTC | |
by ikegami (Patriarch) on Aug 10, 2006 at 05:51 UTC |