in reply to Re^2: Using an array element as a loop iterator
in thread Using an array element as a loop iterator
That prints all four elements of b
and then a contains : [1, 13, 3]. So it does not correspond to your C-style for loop where you only print the first three elements, and the second value in the declaration of a is just thrown away.10 11 12 13
To achieve the same result in Perl you can do:
@a = 1..3; @b = qw/2 4 7 9/; for (@b) {$a[1] = $_; say; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Using an array element as a loop iterator
by gurpreetsingh13 (Scribe) on Nov 08, 2013 at 15:17 UTC | |
by AnomalousMonk (Archbishop) on Nov 08, 2013 at 16:27 UTC | |
by Eily (Monsignor) on Nov 08, 2013 at 17:14 UTC | |
by LanX (Saint) on Nov 08, 2013 at 19:45 UTC | |
by Eily (Monsignor) on Nov 08, 2013 at 20:14 UTC | |
by LanX (Saint) on Nov 08, 2013 at 20:19 UTC | |
by gurpreetsingh13 (Scribe) on Nov 09, 2013 at 08:59 UTC |