Lesson 8 | Getting started with CGI |
Objective | Explore the role of MIME headers in a CGI program. |
How to get started with Perl and CGI
Because the process of running your first CGI program is complex enough in itself, we will first consider a simple CGI program that sends a brief message back to your browser before we pursue the added complexity of using forms. A CGI program sends its output back to the client as part of the response from the server.
Because this can be any sort of output that a Web client can handle, you need to first specify what sort of data you will be sending. Usually it will be HTML (just another Web page for all intents and purposes), but since it is possible to send anything,
you will need to explicitly tell the client what you are sending.
MIME header
HTTP_ACCEPT: The formats accepted by the browser. This information is optionally supplied by the browser when it first requests the page from the server. In our example, the default types accepted include all of the major graphics types (GIF, JPEG, X bitmap),
as well as all other MIME types (*/*).
Sending Information Back to the Browser
print "Content-type: text/html\n\n";