#!/usr/bin/perl

$infile = shift @ARGV;
open(IN, "<$infile") || die "$infile: $!\n";

sub whicharg {
    for (my $i = 0; $i <= $#ARGV; $i++) {
	return $i if ($ARGV[$i] eq $_[0]);
    }
    return undef;
}

print "timeval double\n";

print("title \ncomparison of ", join(" and ", @ARGV), "\n");
print("xlabel\ntime of observation\nylabel\nRTT (seconds)\n");

while (<IN>) {
    my $index;
    chomp;
    split;

    $index = whicharg($_[0]);
    next unless defined($index);
    next unless $_[5] eq 'rtt';
    printf(". %f %f %d\n", $_[6], $_[7] - $_[6], $index);
}

print "go\n";
