damien krotkine <dkrotk...@gmail.com> writes: > I'm using this code to get a list of only the odd elements of an > array. The resulting list must have the same order as the array. > > map { state $f; ($_) x (++$f%2) } @array;
If you want only to get some elements of a list is is much more obvious to use grep instead of map: grep { ++$f%2 } @array Then use the magical flip-flop variable: grep { $|-- } @array And remove unneeded syntax grep$|--,@array //Makholm