in reply to Switch the odd/even elements of an array

I would basically do what you do, except that I'd create the list of indices first, and then rearrange the target array:

my @foo = (1..8); my @indices = map { $_*2 +1 => $_*2 } 0..(@foo / 2)-1; @bar = @foo[ @indices ];