Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: how do foreach and while affect an array?

by zdog (Priest)
on Sep 12, 2004 at 20:27 UTC ( #390453=note: print w/replies, xml ) Need Help??

in reply to Re: how do foreach and while affect an array?
in thread how do foreach and while affect an array?

You can iterate through arrays using foreach and while w/o worrying about losing data.

Yes, foreach() ( aka for() ) does iterate through the array, and it does not affect the contents of the array on its own. But just to be clear, one doesn't iterate through arrays with while().

while() can indeed be utilized to run through an array, but whether that affects the contents of the array depends on the implementation. In the end, while() does not operate on arrays on its own in any fashion.

Zenon Zabinski | zdog |

  • Comment on Re^2: how do foreach and while affect an array?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://390453]
[erix]: ok, but mainainability comes after it has been made to work :)
[erix]: maybe I should have cobbled together a more simple example
[erix]: the main question is whether repeating groups get captured. I thought they did but it looks they do not.
[erix]: or they probably get overwritten when the repeating is done

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2018-01-19 08:39 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (216 votes). Check out past polls.