http://qs1969.pair.com?node_id=891512


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

use xor on the array indexes:
my @foo = (1..8); my @bar = @foo[map {$_ ^ 1} (0..$#foo)]; print "@bar";
Outputs
2 1 4 3 6 5 8 7
- Miller