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

what's the point of Foreach?

Thread Next
James Taylor
March 1, 2002 11:51
what's the point of Foreach?
Message ID:
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 

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About