On Fri, May 20, 2005 at 09:21:04PM -0500, Peter Rabbitson wrote: > When perl executes a foreach loop, it creates some kind of array of all the > iterators and then goes over them one by one. Is the current index pointer > accessible from inside the loop? I was unable to find anything related in > perlvar.
No, it is not. > P.S. I know it is trivial to add an incrementing counter at the end of > the loop, but it seems redundant to me, since perl got to do something > similar anyway just to keep track of its own state. The reason this has not been built into the language is that there would be an overhead associated with each loop to maintain this variable. The Perl5 team felt that this was not acceptable given that most loops do not need this information and, and you have noted, it's trivial to do the work yourself if necessary, if not always terribly elegant. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>