>From "Learning Perl" "It turns out that, inside the Perl grammar, the keyword "foreach" is exactly equivalent to the keyword "for". That is, any time Perl sees one of them, it's the same as if you had typed the other. Perl can tell which you meant by looking inside the parentheses. If you've got the two semicolons, it's a computed "for" loop (like we've just been talking about). If you don't have the semicolons, it's really a "foreach" loop;"
"In Perl, the true "foreach" loop is almost always a better choice." >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:activeperl- >[EMAIL PROTECTED] On Behalf Of Thurn, Martin >Sent: Friday, April 07, 2006 8:42 AM >To: DZ-Jay; Conrad, Bill (ThomasTech) >Cc: [email protected] >Subject: RE: foreach question > > >> In fact, "foreach" is just a short hand for those times when >> you only need the contents of the list or to perform an >> operation "for each item", but have no need for the index or >> the list itself. > > Not sure what you're implying here, but the fact is: there is NO >DIFFERENCE between 'foreach' and 'for' in perl. You can use the >keywords interchangeably. DWIM rules! > > If somebody can prove me wrong, I look forward to seeing it. > > - - Martin > >_______________________________________________ >ActivePerl mailing list >[email protected] >To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
