SPUG: Re: scalar swap challenge (SPOILER!)

Creede Lambard creede at penguinsinthenight.com
Wed Oct 8 17:51:49 CDT 2003


I think I sent my entry directly to Michael . . . 

my @stack;

unshift @stack, $a;
unshift @stack, $b;
$a = shift @stack;
$b = shift @stack;

Note that this will work with any scalar, not just integers. Note that it also
uses temporary storage, but not a temporary scalar.

So far I think I like the approach using ^= best.



More information about the spug-list mailing list