#!/usr/bin/perl -lw use strict; my $a = 1; my $b = 2; sub swap { my @in = \( @_ ); # create our references, although pointless here ${$in[0]}^=${$in[1]};${$in[1]}^=${$in[0]};${$in[0]}^=${$in[1]}; } print "$a $b"; swap($a,$b); print "$a $b"; __DATA__ output: 1 2 2 1