while (my $next = $iter{next}->()) { # ... last if $iter{exhausted}->(); }