in reply to Breaking from a foreach loop, returning to position

In Python I would have told you to use a generator, with the yield statement (which allows to interrupt the execution of a function to yield a value, and resume the execution later) :).

As far as I could tell though, it looks like grep might just do what you want, although it doesn't have the "evaluation-laziness" of yield. grep will allow you to extract the elements that match a condition from a list:

my @list = 1..10; my @odd = grep { $_ % 2 } @list; # Now you can work on the elements of @odd one element at a time, by r +emoving them as you use them if you want.