#!/usr/bin/perl

$ncols=$ARGV[1]-1;
$justification=$ARGV[2];


print "\\begin{deluxetable}{";
for($i=0; $i<=$ncols; $i++)
{
    print "c";
}
print "} \n";
print "\\tablecaption{\\label{} }\n";
print "\\tablewidth{0pt}\n";
print "\\tablecolumns{",$ncols+1,"}\n";
print "\\tablehead{ \n";

$count=0;
open(FILE,"$ARGV[0]") || die("Usage: './maketable  FILE  numberofcolumns  l|r|c'");
while(<FILE>)
{
    if($count==0)
    {
	@titlerow=split(":", $_);
	for($i=0; $i<=$ncols-1; $i++)
	{
	    print "\\colhead{",$titlerow[$i],"} \& \n";
	}
	chomp $titlerow[$ncols];
	print "\\colhead{",$titlerow[$ncols],"} \n";
	print "}\n\\startdata\n";
    }
    if($count>0)
    {
	@line=split(":", $_);
	for($i=0; $i<=$ncols-1; $i++)
	{
	    print $line[$i]," \& ";
	}
	chomp($line[$i]);
	print $line[$i]," \\\\ \n";
    }
    $count++;
}
close(FILE);
print "\\enddata\n\\end{deluxetable}\n";
