in reply to Filling buckets

Has anyone done one like this yet? It's really short, but I didn't see it in the thread.

sub split_into { my ($n, @from, @to) = @_; while (@from) { push @{$to[$i++]}, shift @from; i %= $n; } @to; } @results = split_into(3, 'a' .. 'z');

Update: It's a lot like Tilly's last one. But it doesn't have the bad memory behavior. (Ben's has an array that marches downward indefinitely in memory, which is bad.) Mine also has the benefit of not requiring the explicit initialization of the destination array.