Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Toggling vars in each iteration

by Athanasius (Abbot)
on Jan 17, 2013 at 02:41 UTC ( #1013684=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Toggling vars in each iterations
in thread Toggling vars in each iterations

Hello akki_best, and welcome to the Monastery!

$var1 = $var2; $var2 = $var1;

That won’t work, because by the time you get to the second command, the value of $var1 has already been overwritten by the first command. But in Perl, swapping these values is as simple as:

($var1, $var2) = ($var2, $var1);

P.S. Please format your code using <code> tags. See Markup in the Monastery.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re^3: Toggling vars in each iteration
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2015-07-31 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls