in reply to RE: Re: interchanging variables the tough way (BENCHMARK)
in thread interchanging variables the tough way

You can get the xor method to work on large numeric values by changing the swap function to stringify the values first:
sub xor { $a = "$a" ^ "$b"; $b = "$a" ^ "$b"; $a = "$a" ^ "$b"; } $a=999999999999; $b=8888888; print "BEFORE: A=$a B=$b\n"; &xor(); print "AFTER: A=$a B=$b\n\n";
output

BEFORE: A=999999999999 B=8888888
AFTER:  A=8888888 B=999999999999

Replies are listed 'Best First'.
RE: RE: RE: Re: interchanging variables the tough way (BENCHMARK)
by tye (Sage) on Aug 30, 2000 at 21:09 UTC

    Though this adds trialing nulls ("\0") to whichever string is shorter. ):

            - tye (but my friends call me "Tye")