in reply to Return a list or an iterator
Either way, your iterator is only expecting to be called in scalar context; you could expand it to allow returning the remaining list when the iterator is called in list context:
(It is a little inconsistent to use return in sub foo but not in the anonymous sub.)sub foo { # ... wantarray ? @foo : sub { wantarray ? splice @foo : shift @foo } }; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Return a list or an iterator
by Anonymous Monk on Apr 17, 2006 at 18:56 UTC | |
Re^2: Return a list or an iterator
by gaal (Parson) on Apr 17, 2006 at 10:29 UTC |