in reply to Re^2: In need of a sequence iterator.
in thread In need of a sequence iterator.

Now that I've had a chance to sleep, here's a solution that accepts either a count or an arrayref.

sub genIterator { my ($len,$array) = @_; $array = [0..$array-1] if $array =~ /^\d+$/; die "Don't know what to do with $array" unless ref $array eq "ARRA +Y"; my @list = (); return sub { return undef unless @$array; if (@list < $len) { push @list, 0; } else { $list[-1]++; while (@list && $list[-1] >= @$array) { pop @list; $list[-1]++ if @list; } } return @list ? join("", @$array[@list]) : undef; } }