On Sat, Feb 12, 2005 at 03:55:40PM -0500, Uri Guttman wrote:
: LW> What's going on here is that the loop body is a closure that is
: LW> cloned upon entry to the loop (you're logically passing a closure
: LW> to the "for()" function that implements the loop), so if there's a
: LW> FIRST ins
> "LW" == Larry Wall <[EMAIL PROTECTED]> writes:
LW> : JG> The first time use_first is called it will print
LW> : JG> entering loop
LW> : JG> 1
LW> : JG> 2
LW> : JG> leaving loop
LW> :
LW> : JG> but subsequently it will print
LW> : JG> 1
LW> : JG>
On Sat, Feb 12, 2005 at 12:44:05PM -0500, Uri Guttman wrote:
: > "JG" == Joe Gottman <[EMAIL PROTECTED]> writes:
:
: JG>sub use_first()
: JG>{
: JG> for 1..2 {
: JG> FIRST {say 'entering loop';}
: JG> say $_;
: JG> L
> "JG" == Joe Gottman <[EMAIL PROTECTED]> writes:
JG>sub use_first()
JG>{
JG> for 1..2 {
JG> FIRST {say 'entering loop';}
JG> say $_;
JG> LAST{say 'leaving loop';}
JG> }
JG> }
JG> The first time use_first is called it will pr
Often when I write a loop I want to run some code at loop entry time. It
would be nice to have a closure trait for this, similar to NEXT for loop
continuation or LAST for loop termination, but there isn't one. I don't
think either FIRST or ENTER do quite what I want. FIRST runs only once,
whi