http://qs321.pair.com?node_id=1214136


in reply to Re^3: Can I check if a loop's scope is entered for the first time? (Devel::Callsite)
in thread Can I check if a loop's scope is entered for the first time?

Well, that took longer than I expected. ;-)

I just uploaded a new release of Var::Pairs (version 0.003005)
that solves the problem of resetting an iterator on premature termination
of the surrounding loop. It does so by using Scope::Upper::reap()
to install a "destructor" for each iterator when execution leaves
the surrounding scope.

Take another look; I think it's likely this technique would also work for you.

Damian