SPUG: English-speak about Perl-speak "for" loops

Ingy dot Net ingy at ttul.org
Fri Sep 15 23:34:43 PDT 2006


On 15/09/06 17:49 -0700, Jack Foy wrote:
> Michael R. Wolf wrote:
> >  for(init; entry-condition; iteration) { block }
> >  for loop-variable (list) { block }
> ...
> > If you use "for" for both Perl-speak styles, how do you English-speak about
> > it to avoid ambiguity?
> 
> Simple: don't use the first form.  :-)
> 
> I assert that using the C-style for-loop is un-Perlish.  In most cases,
> if you're numerically indexing your arrays, you're missing a better way
> of expressing the code.

How would you better express:

    for (my $i = 0; $i < @array - 1; $i++) {
        $array->[$i + 1] += $array[$i];
    }

The C style loop has its place in Perl.

Cheers, Ingy

> -- 
> Jack Foy <jack at foys.net>
> _____________________________________________________________
> Seattle Perl Users Group Mailing List  
>      POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>     MEETINGS: 3rd Tuesdays
>     WEB PAGE: http://seattleperl.org/


More information about the spug-list mailing list