[Israel.pm] C style for loop

Roman M. Parparov roman at parparov.com
Fri Feb 24 07:55:37 PST 2012


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

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



More information about the Perl mailing list