in reply to Useful uses of redo?
The canonical example is handling continuation lines.
while ( <> ) { if ( s/\\$// ) { chomp; $_ .= <>; redo; } # .. }
Here, the code tests if it can remove a backslash from the end of a line, and if so, gobbles another line from the input and tries again. If the new line ends in a backslash, it will redo again in the new iteration.
NB: this would be more involved in real code — the above snippet is merely for demonstration and a little simpleminded and subtly buggy.
Makeshifts last the longest.
|
|---|