in reply to Useful uses of redo?

I've used redo once in the last two years or so. Parsing a file with a rather involved format I had several subs to handle specific sections; these sections did not have a closing token of any kind, so the subs had to get a token to find out that they don't recognize it and that their section is over. Rather than futzing it so I can "unget" a token, it seemed easier to just return the current one and redo in the main loop.

so:

while(<FILE>){ if(/Foo/){ $_ = foo(); redo; } elsif { # do lots of other stuff } } sub foo { while(<FILE>){ if(/something or other/){ # so stuff } else { return $_; } } }

Note that foo() doesn't see the line containing "Foo" nor did it need to in this case.

Worked well, certainly don't know if that's doing the Right Thing.