[ back to toc ]

Content-type html

Date: 2002/01/25 19:27

Q:
Peter,
I am taking my first cgi/ perl class at Penn State. As an
inexperienced,non programming novice,with poor syntax,
I'm trying to display the following script in a browser. It is a nine cell
table with different colors for each cell with three of the nine numbers
hyperlinked. I know how to FTP and copy to the proper bin and I do know
the path but when I call it through HTTP, it won't show in the browser.
Here it is!#!C:/usr/bin/perl.exe

print "Content-type: text/html\n\n";

print "<html><head>\n";
print "<title>Table Assignment</title></HEAD>\n";
print "<body bgcolor="#FFFFFF">\n";
print "<table width="75%" border="1" height="365" bordercolor="#CCCCFF"
bgcolor="#FFFFFF" align="center">\n";
print "<tr bgcolor="#99FFFF" bordercolor="#CCCCCC">\n";
print "<td width="34%" bgcolor="#CCCCFF">\n";
print "<div align="center"><font size="+7">1 </font></div>\n";
print "</td>\n";
print "<td width="32%" bgcolor="#66FF33">\n";
print "<div align="center"><font size="+7">2</font></div>\n";
print "</td>\n";
print "<td width="34%" bgcolor="#FF9999">\n";
print "<div align="center"><font size="+7">3</font></div>\n";
print "</td>\n";
print "</tr>\n";
print "<tr bgcolor="#99FFFF" bordercolor="#CCCCCC">\n";
print "<td width="34%" bgcolor="#FFCC99">\n";
print "<div align="center"><font size="+7">4</font></div>\n";
print "</td>\n";
print "<td width="32%" bgcolor="#CCFFCC">\n";
print "<div align="center"><font size="+7"><a
href="http://www.yahoo.com">5</a></font></div>\n";
print "</td>\n";
print "<td width="34%" bgcolor="#FFFF33">\n";
print "<div align="center"><font size="+7">6</font></div>\n";
print "</td>\n";
print "</tr>\n";
print "<tr bgcolor="#99FFFF" bordercolor="#CCCCCC">\n";
print "<td width="34%">\n";
print "<div align="center"><font size="+7"><a
href="http://www.altavista.com">7</a></font></div>\n";
print "</td>\n";
print "<td width="32%" bgcolor="#FFFFCC">\n";
print "<div align="center"><font size="+7">8</font></div>\n";
print "</td>\n";
print "<td width="34%" bgcolor="#CCCCFF">\n";
print "<div align="center"><font size="+7"><a
href="http://www.excite.com">9</a></font></div>\n";
print "</td>\n";
print "</tr>\n";
print "</table>\n";
print "</body>\n";
print "</html>\n";

Thank You

A:
It will not show in the browser as you say. But what does it show? The
program is simple and thus should work. I recommend that you use

print <<END;
html code in
many lines
END

style multi line strings though.

You can also try to write

print "HTTP/1.0 200 OK\nContent-Type: text/html\n\n";

instead. Other than that the script is OK and should work. This is a web
server configuration problem (most probably).

Regards,
Peter

[ back to toc ]