Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: difference between for and foreach?

by merlyn (Sage)
on Jan 20, 2001 at 18:12 UTC ( [id://53241]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to difference between for and foreach?

The words for and foreach are interchangable, syntactically. (This is what most people are saying when they say there's "no difference").

However, as Larry intended it, there's a "for" statement, with 3 parts, like C's same-named, and a "foreach" statement, like csh's same-named loop. And they do nicely different things, even though they're both basically loops.

So, yes, there's a difference, except when there's not a difference. If you check the Llama, we're very careful to describe the two kinds of loops seperately. They have different uses and syntax.

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: difference between for and foreach?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://53241]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.