in reply to I need a different continue
Your foreach won't know how many times to loop until it has already started execution. What you could do is keep a queue of todos and every time you start the loop block, do anything needing to be finished. The last time through your loop the todos generated during the loop won't be executed and will go away.
{ my @todos; foreach my $elt ( ... ) { $_->() for @todos; # Correction for Roy Johnson @todos = (); ... push @todos, sub { print "$elt\n" }; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: I need a different continue
by Roy Johnson (Monsignor) on Dec 09, 2004 at 18:26 UTC |