Friday, June 24, 2011

Simple Perl CGI to generat HTML

open (IN,"table.txt") or die "Cant Open $!";
print start_html('HTMLIZE');

# get the caption
chomp($caption = <IN>);

# get the column headers
chomp($colhead = <IN>);
@col_head = split("\t",$colhead);

# Get the data into an array. 
# The first item in each array is the header, the rest is
# the data cells
while (<IN>) {
     chomp;
     ($rowhead,@data) = split("\t");
     push(@rows,th($rowhead).td(\@data));
}

# Print out the table
print img{src=>'ENSG00000189366.png',align=>'center'};

print hr;

print table({-border=>''},
          caption($caption),
          TR([th(\@col_head),@rows])
      );
close IN;
print end_html;

No comments:

Post a Comment