The Perl redo statement goes directly to the first line of the loop body and starts executing the loop repeatedly. The statements after the redo statement are no longer executed, and the continue statement block is no longer executed.
The continue statement can be used in while and foreach loops.
The syntax format is as follows:
redo [LABEL]
LABEL is optional.
The redo statement with the label modifier LABEL means that the loop control flow is directly transferred to the first line of the statement block associated with the label modifier LABEL to start execution, instead of executing the statements after the redo statement and the continue statement block;
The redo statement without the label modifier LABEL means that the loop control flow is directly transferred to the first line of the current statement block to start execution, instead of executing the statements after the redo statement and the continue statement block;
If it is in a for loop or with a continue statement block, the increment list and continue statement block in the for loop will no longer be executed;
Executing the above program, the output result is:
a = 0a = 1a = 2a = 3a = 4a = 6a = 7a = 8a = 9