Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: C-style for loop

by JavaFan (Canon)
on Nov 15, 2008 at 19:57 UTC ( #723842=note: print w/replies, xml ) Need Help??

in reply to C-style for loop

Right ?
Maybe, maybe not. What's better depends on your preferences, and the task at hand.

About the only thing that's wrong is assuming that without further knowledge, one style is better than the other.

Replies are listed 'Best First'.
Re^2: C-style for loop
by wol (Hermit) on Nov 17, 2008 at 17:06 UTC
    Indeed. C style loops can't be that bad - otherwise they wouldn't be part of the language, would they? :-)

    Certainly, C style loops are great if you're a good C programmer, and a novice Perl programmer: intuitive, predictable, easy.

    And I guess that described quite a lot of us here at some point in our lives?

    .sig : File not found.

      So everything that is part of Perl is undiluted goodness? How about the two parameter open or the .. operator that is two completely different an unrelated operators depending on context (where the context can be very subtle at times)?

      Perl's for loop is much closer to "intuitive" than C's for loops. Sure, C's for loops are comfortable for a C programmer, but that doesn't make them intuitive, predictable or easy compared with Perl's loops.

      Perl is a different language than C. Just because you can write C (or FORTRAN for that matter) in Perl doesn't mean you should. Embrace the Perly goodness and cast off the C baggage - use Perl for loops unless you really, really, really absolutely can't avoid using a C style loop.

      Perl reduces RSI - it saves typing

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2021-02-28 01:37 GMT
Find Nodes?
    Voting Booth?

    No recent polls found