in reply to Re: Strangness with arrays
in thread Strangness with arrays

Actually, the loop variable is always aliased to the loop elements, even when you say something like for (@a1, @a2, @a3) or even for (qw(foo bar baz 1 2 3), @a1). If you really want to force flattening, you need to force a copy of the data structure: for(@{[@a1, @a2, @a3]})

Update: point taken.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^2: Strangness with arrays
by Elian (Parson) on Jul 10, 2002 at 21:01 UTC
    You misunderstood.

    Yes, the loop variable always aliases to the individual scalars. This is true. But in the case presented, with a bare, single array in for/foreach's list, perl also turns the loop into an iteration over the array itself, rather than flattening the array and iterating over the list of scalars.