Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Exchanging Variables

by robsv (Curate)
on Aug 10, 2001 at 02:00 UTC ( #103674=note: print w/ replies, xml ) Need Help??


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):

$a = 598; $b = 77; $a = $a ^ $b; $b = $a ^ $b; $a = $a ^ $b; print "$a $b\n";
Use the ($a,$b) = ($b,$a) version, though. I just put this up for fun: TMTOWTDI!

- 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.


Comment on Re: Exchanging Variables
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://103674]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-12-21 11:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls