in reply to Re: alternate array elements
in thread alternate array elements

Thanks all!

toolic I didn't know of supersearch so that's useful

cdarke I like the keys approach, hadn't thought of that at all and presumably it's fast, will try that next time if I don't need to preserve order.

For posterity, I decided I actually needed the ODD indices (fwiw, the array has duplicate values in it and I'm porting VBA code which uses 1-based arrays, hence want to keep $all[0] as it = undef) so I used:

@odd = @all[grep($_%2==0, 0..$#all)];

or seomething like that. I guess the not would be faster tho, but I think it'd confuse my readers more, they'll already be struggling with grep, % and $#!!

Replies are listed 'Best First'.
Re^3: alternate array elements
by Anonymous Monk on May 20, 2010 at 15:17 UTC
    gah should have said evens - basically edited solution by almac at the top now