redo operator in Perl restarts from the given label without evaluating the conditional statement. Once redo is called then no further statements will execute in that block. Even a continue block, if present, will not be executed after the redo call. If a Label is given with the redo operator then the execution will start from the loop specified by the Label.
Syntax: redo Label
Returns:
No Value
Example 1:
$a = 1;
GFG: {
$a = $a + 5;
redo GFG if ( $a < 10);
}
print ( $a );
|
Example 2 (Redoing a loop):
$a = 1;
$count = 1;
GFG: while ( $count < 10) {
$a = $a + 5;
$count ++;
redo GFG if ( $a < 100);
}
print ( "$a $count" );
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!