<?xml version="1.0" encoding="windows-1252"?>
<node id="891512" title="Re: Switch the odd/even elements of an array" created="2011-03-04 15:31:51" updated="2011-03-04 15:31:51">
<type id="11">
note</type>
<author id="580841">
wind</author>
<data>
<field name="doctext">
use &lt;a href="http://perldoc.perl.org/perlop.html#Bitwise-Or-and-Exclusive-Or"&gt;xor&lt;/a&gt; on the array indexes:

&lt;code&gt;
my @foo = (1..8);

my @bar = @foo[map {$_ ^ 1} (0..$#foo)];

print "@bar";
&lt;/code&gt;

Outputs

&lt;code&gt;
2 1 4 3 6 5 8 7
&lt;/code&gt;

- Miller</field>
<field name="root_node">
891508</field>
<field name="parent_node">
891508</field>
</data>
</node>
