Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

swap

Posted on 2001-06-17
1
Medium Priority
?
1,252 Views
Last Modified: 2012-06-27
$a=1
$b=2

how do I swap $a and $b in a "one liner"?
0
Comment
Question by:huitema
1 Comment
 
LVL 8

Accepted Solution

by:
shlomoy earned 200 total points
ID: 6199392
$a=1;
$b=2;
($a,$b)=($b,$a);  # the requested one liner :-)
print "$a $b\n";
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question