Connie Chan wrote at Sat, 27 Jul 2002 15:15:03 +0200: > With this, I'll have a question again =) > how about : for (my $x = 0; $x <= 100; $x++){} ? > In every loop, $x return the value to the middle, > and the middle design to roll another loop or not. It is doing something similar to >if then else, > but it also returning vals and condition signals... So.... what is this ? And when I >write as > for (0..100){} there is quite no difference, still an invisible $x, as $_... >so...sorry, dunno how > to ask.. =)
Allthough, it's better written as for my $x (0 .. 100) { ... } Looking to the perldoc, gives us the translation to the while loop: Perl's C-style "for" loop works like the corresponding "while" loop; that means that this: for ($i = 1; $i < 10; $i++) { ... } 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 lex- ical scope of those variables is exactly the "for" loop (the body of the loop and the control sections). Cheerio, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]