for ( # Lexical scope
my($idx,$x,$y)=(0,0,0); # Initializer
$idx<10; # Condition
++$idx, $x+=2, $y+=3 # Prep for next iteration.
) {
print "$idx, $x, $y\n";
}
####
{ # Lexical scope
my( $idx, $x, $y ) = ( 0, 0, 0 ); # Initializer
while( $idx < 10 ) { # Condition
print "$idx, $x, $y\n";
}
continue { # Prep for next iteration.
++$idx;
$x += 2;
$y += 3;
}
}
####
$ perl -MO=Deparse,-x9 ./mytest.pl
# Decomposition of the "for" loop:
while ($idx < 10) {
print "$idx, $x, $y\n";
}
continue {
++$idx, $x += 2, $y += 3
}
# Decomposition of the "while" loop (essentially it's unchanged):
{
my($idx, $x, $y) = (0, 0, 0);
while ($idx < 10) {
print "$idx, $x, $y\n";
}
continue {
++$idx;
$x += 2;
$y += 3;
}
}
./mytest.pl syntax OK