On Tue, May 07, 2002 at 12:27:08PM -0500, Allison Randal wrote: > On Tue, May 07, 2002 at 03:15:48PM +0100, Graham Barr wrote: > > > > LAST Executes on implicit loop exit or call to last() > > Loop variables may be unknown > > Not exactly "unknown". It's just that, in a few cases, their values may > have changed by the time the LAST block is executed.
OK, unspecified. > > > And I think this thread is proposing > > > > FIRST A PRE block that is executed only on the first itteration > > of the loop > > > > BETWEEN A PRE block that does not execute for the first iteration > > of the loop. > > > > So FIRST and BETWEEN are just shorthand for > > > > my $count; > > loop { > > PRE { > > if ($count++) { > > # BETWEEN code here > > } > > else { > > # FIRST code here > > } > > } > > } > > Almost. What people are pushing for is more like: > > BETWEEN A NEXT block that does not execute for the last iteration > of the loop. IMO, it cannot. That is because you cannot always know if you are at the end of a loop until you have executed the condition. Therefore BETWEEN would have to be a PRE block. > This may seem like a trivial difference at first glance, but it's a > matter of scope. The latter interpretation means that code such as: > > for 1..3 -> $thing { > print $thing _ ", "; > > BETWEEN { > print $thing _ "\n"; > } > } > > Will output: > 1, 1 > 2, 2 > 3, > > Not: > 1, 2 > 2, 3 > 3, But consider when this is a while loop, how do you stop BETWEEN being called before the last iteration. > Which seems intuitively right. Not to me :-) Graham.