7.2. List Assignment

my ($x, $y, $z);
($x, $y, $z) = (2, 3, 7);    # nearly the same as $x=2; $y=3; $z=7;
($x, $y)     = (8, 1, 5);    # ignore 5
($x, $y, $z) = (3, 4);       # $z will be undef

A regular question on job interviews:
How can we swap the values of 2 variables, let say $x and $y? 


If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed