in reply to Re^3: I need a different continue
in thread I need a different continue
As I've already shown, (and you have shown a slightly different way) this problem can be solved with a semaphore variable and a check of the sempahore each trip through the loop. I just don't like that solution because it seems messy and wonder if there is a cleaner way. I was hoping to find some syntacical thingy that behaves kind of like a join, but with blocks of code rather than array elements. Here's some pseudo code to demonstrate what I had in mind.
lock_db_tables(); # lock tables and/or start a transaction # in a database independent way # 1100 lines of preparation that requires a database lock # must be in same transaction as first iteration of loop # below foreach my $id (@list_o_object_ids) { my $obj = new Thingy($id); # gets stuff from db # make changes, save back to db. (about 900 lines in my case) unlock_tables(); } join { lock_db_tables(); }
The lock_db_tables() within the join block would be executed between each loop iteration, but not before the first iteration, nor after the last iteration.
"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: I need a different continue
by Jenda (Abbot) on Dec 17, 2004 at 17:05 UTC |