in reply to next and last within subs

I would do something like:

sub foo { # do things return (1 and (complex condition)) } while (main condition) { # do things last if foo; # do more things }