in reply to Re: iterator w/ wantarray()
in thread iterator w/ wantarray()
Problem solved
I realized that it is a closure!
You are right. The sub counter is modified like this
and it works OK.
Thank you for your help.
# # My fixed counter() # sub counter { my ($from, $to, $step)= @_; $step ||= 1; return sub { return if $from > $to; my $value=$from; $from +=$step; return $value; }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: iterator w/ wantarray()
by tobyink (Canon) on Apr 27, 2020 at 07:09 UTC |