Receiving CGI-program arguments from 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:
                                     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 module

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

Table of Contents.
Previous | Next.