Bob Showalter wrote:
> 
> Well, it only works for integers. It's because of the way ^
> (bitwise xor) works. Given x=0 and y=1, for instance:
> 
>    x = x ^ y    y = y ^ x   x = x ^ y
>    x = 0 ^ 1    y = 1 ^ 1   x = 1 ^ 0
>    x = 1        y = 0       x = 1

Actually in perl it works with strings as well.  :-)

$ perl -le'
$x = "abcde"; $y = "fgh";
print "\$x = $x  \$y = $y";
$x ^= $y;
$y ^= $x;
$x ^= $y;
print "\$x = $x  \$y = $y";
'
$x = abcde  $y = fgh
$x = fgh  $y = abcde



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to