sub next { my ($self) = @_; if (...) { return; } else { return ...; } } while (my ($arg) = $i->next()) { ... }