#!/usr/local/bin/perl

$command = "@ARGV";

open COMMAND, "|$command";
while (<STDIN>) {
    @f = split;
    if ($f[4] ne $lastx || $f[7] ne $lasty) {
	if ($lastx ne "") { close COMMAND or warn $! }
	open COMMAND, "|$command";
	($lastx,$lasty) = @f[4,7];
    }
    print COMMAND $_;
}
close COMMAND or warn $!;

