I'm posting a second follow-up to your thread, because I think that one important use of redo hasn't gotten proper attention (including in my previous followup).
Some of the examples listed are using redo in a bare block, which essentially creates a loop whos termination is going to rely on logic within the block placing a call to last.
But remember also that redo will repeat the current iteration of a loop, without going through the loop's conditional or next-iteration stage first. Consider the following example:
my @array = qw/this that those these/; foreach my $word ( @array ) { print $word, "\t"; redo if $word =~ m/that/; }
The output will be "this that that that...." because redo repeats the current iteration without moving on to the next iterant (which would be 'those').
This can be useful if you're trying to keep your loop working on the same iteration until some other condition is met. Perhaps you are blocking, or maybe you're waiting for a mouse click, etc.
Dave
In reply to Re: Useful uses of redo?
by davido
in thread Useful uses of redo?
by kvale
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |