in reply to Exchanging Variables
I also used to code in Pascal (never mind how long ago). If I was swapping two numerics, I used the XOR function. Here's the Perl version (since we ain't Pascal Monks):
- robsv
Update: Aaargh! Ignore me. dailylemma posted this already. That's what I get for starting a reply, going for a soda, then finishing the reply.
Use the ($a,$b) = ($b,$a) version, though. I just put this up for fun: TMTOWTDI!$a = 598; $b = 77; $a = $a ^ $b; $b = $a ^ $b; $a = $a ^ $b; print "$a $b\n";
- robsv
Update: Aaargh! Ignore me. dailylemma posted this already. That's what I get for starting a reply, going for a soda, then finishing the reply.
In Section
Seekers of Perl Wisdom