Forum Moderators: coopster & phranque

Message Too Old, No Replies

HTML Table in Perl

How do I do this?

         

Son_House

12:40 pm on Dec 22, 2001 (gmt 0)

10+ Year Member



I'm trying to have this perl script print out a table but when I tried it I got a 500 internal server error. I know nothing about perl but I'm just trying to change the html part that it prints out. The script worked fine till I added this:

print "<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>";
print "<TR>";
print "<TD ALIGN=\"left\"><img src=\"",$GIF_DIR,"pic1.gif\" height=55 width=41 alt=\"\"></TD>";
print "<TD COLSPAN=\"5\" ALIGN=\"center\" VALIGN=\"top\"><img src=\"",$GIF_DIR,"pic2.gif\" height=55 width=340 alt=\"\"></TD>";
print "<TD ALIGN=\"right\"><img src=\"",$GIF_DIR,"pic3.gif\" height=55 width=41 alt=\"\"></TD>";
print "</TR>";
print "<TR>";
print "<TD COLSPAN=\"7\" ALIGN=\"left\"><P CLASS=\"link\"><A HREF=\"http://www.somesite.com/ "\" TITLE=\"Home Page\">Home</A> > <A HREF=\"http://www.somesite.com/dir/index.htm "\" TITLE=\"Doh\">Doh</A> > Homer</P></TD>";
print "</TR>";
print "</TABLE>";

sugarkane

1:11 pm on Dec 22, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[perl]
print "<TD ALIGN=\"left\"><img src=\"",$GIF_DIR,"pic1.gif\" height=55 width=41 alt=\"\"></TD>";
[/perl]

The problem is the ",$GIF_DIR," part - replace the commas with periods and you should be fine.

Son_House

11:26 am on Dec 23, 2001 (gmt 0)

10+ Year Member



Thanks for your help sugarkane. I tried what you said but it still didn't work. I looked at another script that we found yesterday that used a table and followed what they did. I just got finished testing it and it works now. I'm not sure what was causing the problem as I made all the changes at once.

Here is the code we use:

print "<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0><TR>\n";
print "<TD ALIGN=left><img src=\"",$GIF_DIR,"pic1.gif\" height=55 width=41 alt=\"\"></TD>\n";
print "<TD COLSPAN=5 ALIGN=center VALIGN=top><img src=\"",$GIF_DIR,"pic2.gif\" height=55 width=340 alt=\"\"></TD>\n";
print "<TD ALIGN=right><img src=\"",$GIF_DIR,"pic3.gif\" height=55 width=41 alt=\"\"></TD></TR>\n";
print "<TR><TD COLSPAN=7 ALIGN=left><A HREF=\"http://www.somesite.com\">Home</A> > <A HREF=\"http://www.somesite.com/dir/index.htm\">Doh</A> > Homer</TD></TR>\n";
print "</TABLE>\n";

Key_Master

3:45 pm on Dec 23, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The error can be found in the hyperlinks. Example:

<A HREF=\"http://www.somesite.com/ "\"

The quotation mark wasn't escaped. Try this:

print "<TD COLSPAN=\"7\" ALIGN=\"left\"><P CLASS=\"link\"><A HREF=\"http://www.somesite.com/\" TITLE=\"Home Page\">Home</A> <A HREF=\"http://www.somesite.com/dir/index.htm\" TITLE=\"Doh\">Doh</A> Homer</P></TD>";

I cleaned up the HTML a little too.

Also replace:

\"",$GIF_DIR," with \"$GIF_DIR or \",$GIF_DIR,"

Son_House

8:02 pm on Dec 24, 2001 (gmt 0)

10+ Year Member



Thanks for your help Key_Master. The script is working fine now and looks the way I wanted.

littleman

8:41 pm on Dec 24, 2001 (gmt 0)



I find it simpler to use this approach:
print '<TD ALIGN="right"><img src="' . $GIF_DIR . 'pic3.gif" height=55 width=41 alt=""></TD>';

Damian

10:55 am on Dec 25, 2001 (gmt 0)

10+ Year Member



You could also use this notation, so you don't need to worry about escaping double or single quotes and ending every line with a ; character.
The one character that would have to be escaped in this notation's html is the ~ tilde:

print qq~

<table><tr><td>
your text on the first row of the table
</td></tr></table>

~;

another notation without any escape characters needed (an 'escape word' is used, you can pick any word) :

print <<"ANY_WORD";
<table><tr><td>
your text on the first row of the table
</td></tr></table>
ANY_WORD