in reply to Re^2: next and last within subs
in thread next and last within subs

Sounds like you want to return from the sub, rather than try to manipulate the loop outside the sub.