Monday, December 8, 2008

A simple CGI script

The first task is to write a very simple perl program which just prints out an HTML document. This should include all the usual '' ... '' and '' ... commands. However, there are two things to note.(pl ingore '' sign)

First of all, the first two lines of the print out are special. The first line must be

Content-type: text/html

so that the browser knows what kind of document it is and therefore how to display it. In this case it is a text document of the subclass HTML. You can also send back plain ASCII documents by using text/plain instead. Sound samples and images also have to have the content type specified appropriately. The second line must be blank (ie it must contain just a line feed). This line is reserved for future development.

The second point is really a tip: Strings in perl programs can span over several lines. This means the main part of your perl program can just be one enormous print statement.

original info from
http://www.comp.leeds.ac.uk/Perl/Cgi/simple.html

No comments: