The continue block allows the while loop to act like a for loop : continue « Statement « Perl






The continue block allows the while loop to act like a for loop


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

 








Related examples in the same category

1.The continue block gets executed just before the condition gets evaluated again
2.Example using the continue block