#!/usr/bin/perl -w
use strict;

my $filename = "p03data.csv";

open(TABLE, "$filename") or die "trying";

my @data = <TABLE>;
close TABLE;
my $numdata = @data;
#print $numdata;

print "\\\\\\begin{center}";
print "\\begin{tabular}{|l|l|l|l|l|l|}\n";
print "\\hline ";
foreach my $i (@data) {
	chomp($i);
	my @line = split(/,/,$i);
	my $numline = @line;
	#print "$numline\t$line[$numline-1]\n";
	my $str = "";
	foreach my $j (@line){
		if($j eq $line[$numline-1]){
			$str .= "$j \\\\ ";
		}else{
			$str .= "$j & ";
		}

	}
	if(($line[0] eq "c")||($line[0] eq "variable")){
		$str .= "\\hline";
	}
	print "$str\n";
}
print "\\end{tabular}\n\\end{center}\n";

