This is a variant on an old assembly and 'C' trick that seems to work under Perl (at least, 5.005_03).
my $x = 123; my $y = 666; $x ^= $y ^= $x ^= $y;
It swaps the two values without using an intermediate variable. Now I know that can be done under Perl other ways, but it might make a cool little hack for a JAPH-type person (which is *very* not-me).
For a collection of cute C tricks that someone could port to Perl, see Steve's 'Cute Code' Collection
--Chris
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Potentially useful code fragment for you JAPHer's
by spaz (Pilgrim) on Mar 20, 2001 at 08:58 UTC | |
by japhy (Canon) on Mar 20, 2001 at 20:46 UTC | |
|
Re: Potentially useful code fragment for you JAPHer's
by Dominus (Parson) on Mar 20, 2001 at 22:40 UTC |