in reply to Re: Problem with while loop inside a foreach loop
in thread Problem with while loop inside a foreach loop

Anonymous Monk wrote:

Within the body of the loop, $current_building will be defined and will contain the current index of the loop.

Actually it will contain the array element not the index of the loop or index of the array. I assume that is what you meant.

  • Comment on Re^2: Problem with while loop inside a foreach loop

Replies are listed 'Best First'.
Re^3: Problem with while loop inside a foreach loop
by AnomalousMonk (Archbishop) on May 03, 2013 at 23:03 UTC
    Actually it will contain the array element ...

    Actually, it will contain an alias to the array element. See choroba's reply.

    >perl -wMstrict -le "my @ra = (1, 2, 3, 4); print qq{@ra}; ;; for my $n (@ra) { $n *= $n; } print qq{@ra}; " 1 2 3 4 1 4 9 16