programming-examples/perl/Statement/The continue block allows the while loop to act like a for loop.pl
2019-11-15 12:59:38 +01:00

8 lines
172 B
Perl

$i=1;
while ($i <= 10) {
if ($i == 5) {
print "\$i == $i\n";
next;
}
print "$i ";
}continue {$i++;} # $i is incremented only once