Using the redo statement in a while structure. : Redo « Statement « Perl






Using the redo statement in a while structure.


$number = 1;

while ( $number <= 5 ) {

   if ( $number <= 10 ) {
      print "$number ";
      ++$number;
      redo;  # Continue loop without testing ( $number <= 5 )
   }
}
    
print "\nStopped when \$number became $number.\n";

 








Related examples in the same category

1.redo statement
2.While loop, foreach loop, and block and redo
3.A word-counting program that uses the redo statement.
4.Using a label without a loop and the redo statement