in reply to Re: Re: infinite loop on while (@array)
in thread infinite loop on while (@array)
Im fairly sure that if you look into the documentation again that the c style for loop is actually converted into a while() block. Not the other way round.
Hmm, just doublechecked perlsyn and it seems that they arent clear, nor is the camel, as to whether these are actually handled internally as forms of each other. However the camel has the following interesting addition to the perlsyn:
The for loop can be defined in terms of the corresponding while loop.<super>emphasis added by me</super>Thus, the following:
is the same as:for ($i = 1; $i < 10; $i++) { ... }
(Defining the for loop in terms of a continue block allows us to preserve the correct semantics even when the loop is continued via a next statement. This is unlike C, in which there is no way to write the exact equivalent of a continued for loop without chicanery.)$i = 1; while ($i < 10) { ... } continue { $i++; }
Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: infinite loop on while (@array)
by Kanji (Parson) on Mar 27, 2002 at 14:33 UTC | |
by demerphq (Chancellor) on Mar 27, 2002 at 15:21 UTC | |
by Juerd (Abbot) on Mar 27, 2002 at 15:16 UTC | |
by demerphq (Chancellor) on Mar 27, 2002 at 15:40 UTC |