in reply to Using an array element as a loop iterator
I suppose you didn't write what you thought you were writing. First, square brackets are not used to make a list, like in python, but an arrayref, which is only one element. So @a contains only one element which is [1,2,3]. @b on the other is indeed an array.
Could you write what you were intending to in python? If I translate your code it would be something like:
for each element in @b $a[1] = element print $a[1] done
If you want to use the indexes in @a to go through @b you can either use a slice (EDIT: not splice ...) of @b :
Or loop through @a :@a = (1,2,3); @b = (2,4,6,7); print for @b[@a]; # print for elements of @b with indexes in @a
@a = (1,2,3); @b = (2,4,6,7); for $i (@a) { print $b[$i]; }
NB: As for the error, I guess in for VAR (LIST) VAR can only be a variable, not any lvalue.
In Section
Seekers of Perl Wisdom