On 2/25/12 3:46 AM, sawyer x wrote:
> On Fri, Feb 24, 2012 at 5:55 PM, Roman M. Parparov <[email protected]
> <mailto:[email protected]>> 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. :)
>
>
Recently I found another use:
If I need the index value after the loop. :)

R.

>     R.
>
>     On 2/24/12 12:01 AM, sawyer x wrote:
>      > On Fri, Feb 24, 2012 at 9:41 AM, Stefan Hornburg (Racke)
>     <[email protected] <mailto:[email protected]>
>      > <mailto:[email protected] <mailto:[email protected]>>> 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
>      > [email protected] <mailto:[email protected]>
>      > http://mail.perl.org.il/mailman/listinfo/perl
>
>     _______________________________________________
>     Perl mailing list
>     [email protected] <mailto:[email protected]>
>     http://mail.perl.org.il/mailman/listinfo/perl
>
>
>
>
> _______________________________________________
> Perl mailing list
> [email protected]
> http://mail.perl.org.il/mailman/listinfo/perl

_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to