in reply to Re: Re: Iterating & Playing with Caller's Pads
in thread Iterating & Playing with Caller's Pads

It just irks me that you can't do it. It just seems to me that I should be able to say somthing like ...
... this?
{ my $pos = 0; sub elements(\@$) { my($ar, $n) = @_; my $range = $pos + $n < @$ar ? $pos + ($n - 1) : $#{$ar}; my @ret = @$ar[ $pos .. $range ]; $pos += $n; return @ret ? @ret : (); } } my @ar = qw( foo bar baz one two three ichi ni san xxx ); while(my(@chunk) = elements(@ar, 3)) { print "got: @chunk\n"; } __output__ got: foo bar baz got: one two three got: ichi ni san got: xxx yy
Or am I missing the point?
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Re: Re: Iterating & Playing with Caller's Pads
by shotgunefx (Parson) on Sep 27, 2002 at 13:54 UTC
    My intended one. I gave a very bad example. I'm talking lazy iterators here. The example should have stated "non-destructively" grab elements. I see a lot of uses for this type of scoping, but iterators would be the biggest. I'm talking lazy iterators here.

    -Lee

    "To be civilized is to deny one's nature."