Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by zdog (Priest)
on Sep 12, 2004 at 20:27 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://390453]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-23 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found