in reply to Re^2: iterator w/ wantarray()
in thread iterator w/ wantarray()

This would be a more normal way of doing it. Don't change $from but close over $value.

# # My fixed counter() # sub counter { my ($from, $to, $step) = @_; $step //= 1; my $value = $from; return sub { return if $value > $to; $value += $step; }; }