in reply to Using an array element as a loop iterator

Maybe you should not ignore strict and the other things. You might have got some indication on your mistakes (although I can't check that now, having no environment right now).

[1,2,3] is not an array but a reference to an array. So you may want

my $a = [1, 2, 3];
or
my @a = (1, 2, 3);
This also does not work:
foreach $a[1](@b)
Maybe you want something this:
foreach @$a[1][@b]
but I am really not sure, because the inner array has not been initialized. Finally,
$a[1]
is also probably wrong, since @a is a reference to an array. Please explain what you are really trying to do, I can't really figure out.

Replies are listed 'Best First'.
Re^2: Using an array element as a loop iterator
by gurpreetsingh13 (Scribe) on Nov 08, 2013 at 03:52 UTC
    Sorry, that was a mistake in copy-paste or something. I have updated the same. I don't want a reference, I am mentioning an array there.