While stepping through the code I wrote, I distinctly noted that the
substitution on $_ did NOT affect the array and vice versa. If anyone
insists on adding or deleting elements of an array from within a loop, you
can ... you just have to update either $_ or what $_ is aliased to, like the
original code I posted.

Thanks, John, for reminding me of glob. It does exactly what I need. Perl
has so many parts, it is easy to forget many of them.

Thanks.

-----Original Message-----
From: Paul Johnson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 22, 2003 5:24 PM
To: John W. Krahn
Cc: [EMAIL 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 works very well.
>
> 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 with "splice".   So don't do that.

--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to