AllExperts > Perl & CGI 
Search      
Perl & CGI
Volunteer
Answers to thousands of questions
 Home · More Perl & CGI Questions · Answer Library  · Encyclopedia ·
More Perl & CGI Answers
Question Library

Ask a question about Perl & CGI
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Marty Landman
Expertise
Perl programming using CGI, databases, HTML templating, and website automation.

Experience
Web developer since 1998, owner of Face 2 Interface.

 
   

You are here:  Experts > Computing/Technology > Perl/PHP > Perl & CGI > cgi html problem

Perl & CGI - cgi html problem


Expert: Marty Landman - 7/10/2009

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__

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.