It should be noted that in Perl, at least, this can be done with a single line:

($a,$b)=($b,$a);

This works because Perl tracks both sides of the assignment. It also works with more than one variable:

($a,$b,$c,$d)=($d,$a,$b,$c);

TMTOWTDI.