#!/usr/bin/perl
# w5.14.pl create a 4 column table from a txt file. The text file
# must separate fields with one or more tabs \t 
# Usage:  w5.14.pl table.txt

require("mylib.pl");
&begin_html("Table Creation");

print ("<center>\n");
print ("<table border = 0 width= \"100%\">\n");
open (FH, "$ARGV[0]") or die("Can't open $ARGV[0]");
while (<FH>) {
   if (/^#/) {next;}
   if (/^\s*$/) {next;}
   $_=~ s/\\&/&amp;/g;

   @tdata= split(/\t+/,$_);
   print ("<tr>\n");
   foreach $data (@tdata){
      print ("   <td>$data</td>\n");
   }                      
   print ("</tr>\n");
}					#End while
close (FH);
print ("</table>\n");
print ("</center>\n");
print ("</body></html>");
