CGI-Programming

Receiving CGI-program arguments from the URL

The URL

You can send arguments to a CGI-program by appending a query string to the URL of the program, having the following format:
http://.../program_name?name1=value1&name2=value2&name3=value3
                        --------------------------------------
                                     query string
name1, value1
name2, value2
name3, value3 (and you can add more)

are called name-value pairs, each defining a variable name and its value (content).

The program

The CGI-program receives the query string as an environmental variable, which can be accessed by the command:
$some_variable = $ENV{'QUERY_STRING'};
It then needs to parse the query string and create Perl variables that will contain all of the name value pairs.

The CGI.pm module

The standard Perl distribution now provides you with a package of subroutines, called CGI.pm, that can help you perform various CGI-programming tasks, including parsing the query string.


Table of Contents.
Previous | Next.