#!/usr/bin/perl -w

my $infile = $ARGV[0] if ($ARGV[0]);

open(INFILE, $infile) or die "Could not open log. $!\n";

#my (@Ri, @DC, @heater_integral, @pump_integral, @heatercommand);

foreach(<INFILE>){
    if (/^#/){
        # We process lines beginning with #
	my @line = (split(/\s+/))[1,2,3];
	my ($meas, $val) = split(/\=/,$line[0]);
	$measurements{$meas}++;
#        if($meas eq "Ri") {
#  	    push(@Ri, $val);
#        }
	my $return = push(@{$meas},$val);
#        print "$return = $meas:${$meas}[$return-1]\n";
    }
}

#print "length of Ri is " . $#Ri . "\n";

#@data[0]=("Ri", "DC", "heater_integral", "pump_integral", "heatercommand");
foreach $value (keys %measurements){
    push(@columns, $value);
}

for($i=0;$i<$#Ri;$i++){
    foreach $arr (@columns){
	print "$$arr[$i]\t";
    }
    print "\n";
}
