Make Tables Bearable

You can almost achieve HTML table readability with CGI.pm!

Script II.1.3: vegetables3.pl

 #!/usr/bin/perl

 # Script: vegetables3.pl
 use CGI qw/:standard :html3/;

 print header,
    start_html('Vegetables'),
    h1('Vegetables are for the Strong'),
    table({-border=>undef},
	  caption(strong('When Should You Eat Your Vegetables?')),
	  Tr({-align=>CENTER,-valign=>TOP}, 
	     [
	      th([ '',            'Breakfast',  'Lunch',   'Dinner' ]),
	      th( 'Tomatoes').td([  'no',        'yes',     'yes'   ]),
	      th( 'Broccoli').td([  'no',        'no',      'yes'   ]),
	      th( 'Onions').  td([  'yes',       'yes',     'yes'   ])
	      ]
	     )
	  ),
    end_html;

What it Looks Like

http://localhost/cgi-bin/conference/vegetables3.pl

Output HTML

Here's the typing you saved:
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Vegetables</TITLE>
</HEAD><BODY><H1>Vegetables are for the Strong</H1>
<TABLE BORDER>
  <CAPTION><STRONG>When Should You Eat Your Vegetables?</STRONG></CAPTION>
    <TR ALIGN="CENTER" VALIGN="TOP">
    <TH></TH>
    <TH>Breakfast</TH>
    <TH>Lunch</TH>
    <TH>Dinner</TH></TR>
  <TR ALIGN="CENTER" VALIGN="TOP">
    <TH>Tomatoes</TH><TD>no</TD> <TD>yes</TD> <TD>yes</TD></TR>
  <TR ALIGN="CENTER" VALIGN="TOP">
    <TH>Broccoli</TH><TD>no</TD> <TD>no</TD> <TD>yes</TD></TR>
  <TR ALIGN="CENTER" VALIGN="TOP"><TH>Onions</TH><TD>yes</TD> <TD>yes</TD> <TD>yes</TD></TR>
</TABLE>
</BODY></HTML>

<< Previous Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Sat Jun 3 17:35:27 AKDT 2000