[Israel.pm] C style for loop

sawyer x xsawyerx at gmail.com
Sat Feb 25 03:46:57 PST 2012


On Fri, Feb 24, 2012 at 5:55 PM, Roman M. Parparov <roman at parparov.com>wrote:

> And if you need steps different than one? Non-linear? :)
>

Relatively rare. Most uses are for single step.
If you happen to fall on a case using other steps, you would know to ignore
my warning of C-style for loops. :)


>
> R.
>
> On 2/24/12 12:01 AM, sawyer x wrote:
> > On Fri, Feb 24, 2012 at 9:41 AM, Stefan Hornburg (Racke) <
> racke at linuxia.de
> > <mailto:racke at linuxia.de>> wrote:
> >
> >
> >     How do you write for loops without C-style where you need a running
> >     index inside the loop code?
> >
> >
> > Simple:
> > foreach my $idx ( 0 .. $#array ) {
> >       print $array[$idx], "\n";
> > }
> >
> >
> >
> > _______________________________________________
> > Perl mailing list
> > Perl at perl.org.il
> > http://mail.perl.org.il/mailman/listinfo/perl
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20120225/08eaa2d5/attachment.htm 


More information about the Perl mailing list