develooper Front page | perl.beginners | Postings from March 2002

what's the point of Foreach?

Thread Next
From:
James Taylor
Date:
March 1, 2002 11:51
Subject:
what's the point of Foreach?
Message ID:
20020301200234.A83C520CFE2@shell.hatesville.com
I'm really curious what the point of foreach is considering for does the same 
exact thing? For example:

@myarray = (1 .. 10);

for (@myarray) {
   print "$_\n";
}


Or, you could swap the for for a foreach and the same thing would get 
accomplished...  The only difference I can think of is a slightly different 
handling of hashes.  Is this the only benefit of foreach?  What am I missing 
here

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About