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; }; }
In reply to Re^2: iterator w/ wantarray()
by cmic
in thread iterator w/ wantarray()
by cmic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |