As far as I can see this is just counting in base $count, in which case I'd probably use a string instead:
sub genIterator { my($len, $count) = @_; my $cur = ''; my $lastdig = $count - 1; return sub { if (length($cur) < $len) { $cur .= '0'; } else { $cur =~ s/([^$lastdig])$lastdig*\z/$1 + 1/e or $cur = undef; } $cur; } }
Of course this assumes $count doesn't exceed 10; this approach gets a bit more complex if you need to deal with larger bases.
Hugo
In reply to Re^2: In need of a sequence iterator.
by hv
in thread In need of a sequence iterator.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |