You are here:

Perl & CGI/cgi html problem

Advertisement


Question
QUESTION: #!C:activeperl/perl/bin/perl

print <<EndOfHTML;
content-type:text/html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</head>
<body>
<h1> hello wor</h1>
</BODY>
</HTML>
EndOfHTML
 exit(0);

ANSWER: Try having 2 carriage returns after your first line ie.

content-type:text/html

<!DOCTYPE html PUBLIC "-//W3C//DT   etc..

instead of

content-type:text/html
<!DOCTYPE html PUBLIC "-//W3C//DT   etc..


--
Marty Landman, Face 2 Interface Inc.
Free Database Search App: http://face2interface.com/Products/FormATable.shtml


---------- FOLLOW-UP ----------

QUESTION: thankyou for the repl
yes i did that too. but still teh page doesnt display
it shows error.:(

ANSWER: What is the error? Can you look on the server error log?

---------- FOLLOW-UP ----------

QUESTION: syntax error at D:/Profiles/CHJT87/My Documents/My Website/try.cgi line 8, near "HEAD>", referer: http://localhost/~chjt87/
[Fri Jul 10 12:55:17 2009] [error] [client 127.0.0.1] Execution of D:/Profiles/CHJT87/My Documents/My Website/try.cgi aborted due to compilation errors.,

Answer
I'm not sure what the problem might be. But try this instead:

#!C:activeperl/perl/bin/perl

use strict;
my $html = q|
content-type:text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</head>
<body>
<h1> hello wor</h1>
</BODY>
</HTML>
|;
print $msg;

__END__

Perl & CGI

All Answers


Answers by Expert:


Ask Experts

Volunteer


Marty Landman

Expertise

Perl programming using CGI, databases, HTML templating, and website automation.

Experience

Web developer since 1998, owner of Face 2 Interface.

©2012 About.com, a part of The New York Times Company. All rights reserved.