| Keywords related to control flow of your perl programStart this loop iteration over againDaftar Isi - redo
The redo command restarts the loop block without evaluating theconditional again. The continue block, if any, is not executed. Ifthe LABEL is omitted, the command refers to the innermost enclosingloop. Programs that want to lie to themselves about what was just input normally use this command: - # a simpleminded Pascal comment stripper
- # (warning: assumes no { or } in strings)
- LINE: while (<STDIN>) {
- while (s|({.*}.*){.*}|$1 |) {}
- s|{.*}| |;
- if (s|{.*| |) {
- $front = $_;
- while (<STDIN>) {
- if (/}/) { # end of comment?
- s|^|$front\{|;
- redo LINE;
- }
- }
- }
- print;
- }
redo cannot be used to retry a block that returns a value such aseval {} , sub {} , or do {} , and should not be used to exita grep() or map() operation.
Note that a block by itself is semantically identical to a loopthat executes once. Thus redo inside such a block will effectivelyturn it into a looping construct. See also continue for an illustration of how last , next , andredo work. |
| |
|