Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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 | zdog@perlmonk.org


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://390453]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-12-28 14:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls