Bug#719342: perlsyn: add for my $i; ; example

Damyan Ivanov dmn at debian.org
Sun Aug 11 06:58:50 UTC 2013


-=| jidanni at jidanni.org, 11.08.2013 12:58:37 +0800 |=-
> Package: perl-doc
> Version: 5.14.2-21
> Severity: wishlist
> File: /usr/share/man/man1/perlsyn.1.gz
> 
> perlsyn says
> 
>    For Loops
>        Perl's C-style "for" loop works like the corresponding "while" loop;
>        that means that this:
> 
>            for ($i = 1; $i < 10; $i++) { #BUT HOW DOES ONE USE my HERE the reader wonders
>                ...
>            }
> 
>        is the same as this:
> 
>            $i = 1;
>            while ($i < 10) {
>                ...
>            } continue {
>                $i++;
>            }
> 
>        There is one minor difference: if variables are declared with "my" in
>        the initialization section of the "for", the lexical scope of those
>        variables is exactly the "for" loop (the body of the loop and the

The answer is right there. «in the initialization section of the 
"for"».




More information about the Perl-maintainers mailing list