I think it lies in the history of programming. Traditionally for loops look like this (when written in perl)
for($i=1; $i<=100; $i++){ print "$i\n"; } while foreach loops look like this. @array = qw(one two three); foreach (@array) { print "$_\n"; } Even though you can do for (@array) { ... } and foreach($i=1; $i<=100; $i++){ ... } it's not the "proper" syntax. Yes, it works and there is no difference other than stylistic between them, but I think traditionalists would work up a froth if perl only had the for or foreach command supported. And, as the saying goes, TIMTOWDI, and it wouldn't be perl without that ;) OTOH I could be completely wrong :) HTH John -----Original Message----- From: Jon Molin [mailto:[EMAIL PROTECTED]] Sent: 01 March 2002 15:09 To: [EMAIL PROTECTED] Subject: Re: some questions about for, foreach Jan Gruber wrote: > > Hi, Jon && list ! > On Friday 01 March 2002 11:29 am, you wrote: > > Hi list! > > > > I've always thought there's a difference between for and foreach, that > > for uses copies and foreach not. But there's no diff is there? > > AFAIK there's not really a difference between these two. > > It merely depends on your preferences, readable/maintanable code vs > quick && dirty. if there's no difference, what's the point of having both? I can't see how readable/maintanable would increase by adding functions with the same name, it'd rather increase the confusion... is there really no diff? /jon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------Confidentiality--------------------------. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]