rnaeye has asked for the wisdom of the Perl Monks concerning the following question:
In Python I can do the following:
a, b = 0, 1 while b < 50: print(a, b) a, b = b, a + b
That is shorter version of the following assignment (I think they call it atomic version):
old_a = a a = b b = old_a + b
How do I do the first assignment in Perl? My Perl version is
use warnings; use 5.18.2; my ($a, $b) = (0, 1); while ($b < 50) { say "$a $b"; my $old_a = $a; $a = $b; $b = $old_a + $b; }
Thank you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple assignment in Perl
by Anonymous Monk on Jul 22, 2018 at 23:36 UTC | |
by rnaeye (Friar) on Jul 23, 2018 at 00:23 UTC | |
by tobyink (Canon) on Jul 23, 2018 at 04:34 UTC | |
by rnaeye (Friar) on Jul 24, 2018 at 13:05 UTC | |
|
Re: Multiple assignment in Perl
by bart (Canon) on Jul 24, 2018 at 06:13 UTC |