in reply to Re: Breaking from a foreach loop, returning to position
in thread Breaking from a foreach loop, returning to position

Hmmm, yeah I suppose I could have worded the question better and focus more on that.
To give a bigger idea, this is similar to a debugger. It reads in lines from a file and executes them. I have a foreach loop going through each line of the file, doing some work on it, and continuing. I have a button (Perl/Tk) that, ideally, will halt the process, and when clicked again it continues the process. This needs to be non-blocking, as there are several other processes running at the same time. Outside of the foreach loop, a number of things could be done that pertain to the full program so I feel it's arbitrary, but the file that is being executed should pause on the current line.
So, for example, say the file contains:
--------------

print "Abc\n"; print "123\n"; print "I'm in a loop\n"; ...
etc. etc.
The goal is to loop it through, executing those commands and doing some other operations (this is already implemented), and when I click the "Halt" button, it'll pause while the rest of the program continues it's normal operations. When I hit the button again, it'll continue from where it left off.
Hope that gave a better idea of what I'm trying to accomplish.

Replies are listed 'Best First'.
Re^3: Breaking from a foreach loop, returning to position
by Athanasius (Archbishop) on Aug 26, 2015 at 16:43 UTC