[Israel.pm] sliding window on streaming lines

Gaal Yahas gaal at forum2.org
Sat Jun 5 11:45:00 PDT 2004


On Sat, Jun 05, 2004 at 09:35:45PM +0300, Gaal Yahas wrote:

Oops, just a small correction (hey I said this wasn't tested):

>     CLUSTER: while (push @window, get_cluster($fh)) {
>         shift @window if @window > $N;
>         next  CLUSTER if @window < $N;
>         emit(\@window);
>     }
>     # handle any remaining data
>>>>> unshift @window, "dummy";
>>>>> do { emit(\@window) while shift @window } unless @window == 1;
> 
>     sub get_cluster {
[...]

-- 
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/



More information about the Perl mailing list