Perl redo Statement

The Perl redo statement restarts the current loop without evaluation of the control statement. Further statements in the block will not be executed.

Syntax

The syntax of redo statement is given below:

redo;

Perl redo statement Example

snippet
$a = 5;
while($a < 150){
   if( $a == 40 ){
     $a = $a + 10;
      redo;
   }
   print "a = $a\n";
}continue{
   $a = $a * 2;
}
Output
a = 5 a = 10 a = 20 a = 50 a = 100

In the above program, loop restarts at redo condition that is when $a reaches 40.

Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +