Simple CGI

You need to understand what happens when a CGI program is executed. It all starts when a user requests a URL either by clicking on a link or by typing it into his browser.

The browser sends a request to the web server telling it, “I want to get a resource with the URL named http://www.webserver.com/cgi–bin/hello.pl.”

The web server looks at the URL and breaks it down into its components. The key parts are the directory cgi–bin and the filename hello.pl. Normally, the server would merely return the file hello.pl, but because it’s in the directory cgi–bin and because the server’s configuration tells it that cgi–bin contains CGI programs, it executes the program, capturing the output and sending it to the web server.

The user’s web browser ...

Get Perl for C Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.