In ARM assembler the XOR method is actually equal in speed
to the temporary variable method, and saves a register, and
hence is a standard trick in any ARM programmers macro library.
Eg :-
; Swap r0,r1 using r2 as temporary
; Takes 3 cycles
traditional
MOV r2, r0 ; r2 <- r0
MOV r0, r1 ; r0 <- r1
MOV r1, r2 ; r1 <- r2
; Swap r0, r1 with no extra register
; Takes 3 cycles
xor
EOR r0, r0, r1 ; r0 <- r0 ^ r1
EOR r1, r0, r1 ; r1 <- r0 ^ r1
EOR r0, r0, r1 ; r0 <- r0 ^ r1
Apologies for non perl post, but perspective can be
useful sometimes ;-)