Hi Michael.
Michael Hooten wrote:
> While stepping through the code I wrote, I distinctly noted that the
> substitution on $_ did NOT affect the array and vice versa.
If you watch carefully what Perl is doing, it aliases correctly _until_
you choose to modify the array. After this the correct val
PROTECTED]
Subject: Re: For loop aliasing AND changing an array within a loop.
On Wed, Jan 22, 2003 at 02:10:34PM -0800, John W. Krahn wrote:
> Zeus Odin wrote:
> > I think I read somewhere that you should NOT delete array elements from
> > within a loop. However, the following
Paul Johnson wrote:
>
> On Wed, Jan 22, 2003 at 02:10:34PM -0800, John W. Krahn wrote:
> >
> > I think that you are thinking of hashes.
>
> From perlsyn:
>
> If any part of LIST is an array, "foreach" will get very
> confused if you add or remove elements within the loop
> body, for example
On Wed, Jan 22, 2003 at 02:10:34PM -0800, John W. Krahn wrote:
> Zeus Odin wrote:
> > I think I read somewhere that you should NOT delete array elements from
> > within a loop. However, the following works very well.
>
> I think that you are thinking of hashes.
From perlsyn:
If any part of LIS
Zeus Odin wrote:
>
> When you loop through an array
>
>for(@array){ ... }
>
> should not each array element be aliased into $_: if you change $_, you
> also change the element?
Yes, that is correct.
> This is what I remembered. However, a problem I
> just encountered shook this recollectio
When you loop through an array
for(@array){ ... }
should not each array element be aliased into $_: if you change $_, you
also change the element? This is what I remembered. However, a problem I
just encountered shook this recollection.
I think I read somewhere that you should NOT delete arra