redo 
redo LABEL
redoThe redo operator restarts a loop block without reevaluating the
conditional. The continue block, if
any, is not executed. If the LABEL is
omitted, the operator refers to the innermost enclosing loop. This
operator is normally used by programs that wish to deceive themselves
about what was just input:
# A loop that joins lines continued with a backslash
while (<STDIN>) {
if (s/\\\n$// && defined($nextline = <STDIN>)) {
$_ .= $nextline;
redo;
}
print; # or whatever...
}redo cannot be used to exit a
block that returns a value such as eval
{}, sub {}, or do {}, and it should not be used to exit a
grep or map operation. With warnings enabled, Perl
will warn you if you redo a loop not
in your current lexical scope.
A block by itself is semantically identical to a loop that
executes once. Thus, redo inside such
a block will effectively turn it into a looping construct. See the
section Loop Control in Chapter 4.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access