CGI Programming OpenFAQ

Can I write regular HTML from a cgi script?

Contributors:

It is very common to have a cgi script generate some sort of formatted response that appears to be a regular HTML web page.

There are a couple points to keep in mind. First, HTML treats any number of spaces as a single space and ignores conventional line returns, except inside of the <pre> tag. Second, if you are generating a file to which your script directs the user's browser, you may want to write out line feeds and HTML line breaks to make the HTML more easily readable in the source browser.

A popular way to write large blocks of HTML in Perl cgi scripts is to use HERE documents. This encloses a large segment of information as if it were a single string, saving the typing of a great many quotes!


Previous | Next | Table of Contents

Follow us on Twitter | Contact Us

Copyright 1994-2012 Boutell.Com, Inc. All Rights Reserved.