Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: "Baby" Perl versus "Bad" Perl

by itub (Priest)
on Dec 03, 2005 at 23:19 UTC ( #513870=note: print w/ replies, xml ) Need Help??


in reply to "Baby" Perl versus "Bad" Perl

"for" is for C-style loops and "foreach" is for iterating over arrays.

I'm confused--what's wrong with that? That's the convention used in the perldocs, isn't it? (I personally always type "for" out of laziness, but I don't complain if someone prefers to type "foreach" to iterate over an array).


Comment on Re: "Baby" Perl versus "Bad" Perl
Re^2: "Baby" Perl versus "Bad" Perl
by Ovid (Cardinal) on Dec 03, 2005 at 23:33 UTC

    There's nothing wrong with using that as a convention. However, there is no behavioral difference between "for" and "foreach". Teaching that they aren't the same thing is wrong.

    Cheers,
    Ovid

    New address of my CGI Course.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://513870]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2014-09-22 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls