Damian said: > The C<BETWEEN> block can't decide whether to execute until > it knows whether the loop is going to iterate again. And it can't > know *that* until it has evaluated the condition again. At which > point, the $filename variable has the wrong value. :-( > > The example is a little contrived perhaps, but it might be a common > problem.
I don't think your example is contrived at all. It's just a situation where a little education is all that's needed. The rule could be quite simple: BETWEEN is run before every iteration except for the first iteration. Any variables that you use in BETWEEN are for the iteration that is about to run, not the iteration that just ran. Once people gt that concept things become clear. However, it was because of your conundrum that I first proposed that C<between> (not C<BETWEEN>) is put after the loop. To me that makes it absolutely clear that between isn't part of any one iteration: while whatever() { ... } between { ... } I should admit, however, that this thread has made me prefer BETWEEN inside the block. It keeps open the possibility of loops becoming part of if-elsif chains, even if it's not the choice to allow that right now. -Miko