Loading the CGI Module

Modules are self-contained collections of subroutines and variables that provide specialized functionalities not included in the Perl language. Typically, they handle complex computational tasks. Since they are self-contained code, they are reusable and greatly simplify a programmer's work.

Perl comes with a large number of modules that handle everything from file processing, number crunching, network and, of course, internet programming. This includes a CGI module that provides a convenient interface to server-side programming.

Modules are saved in special module files with the extension .pm. By convention, module names usually start with an uppercase letter.

Modules must be imported in order to be accessible to a script. This is done with the use function. The following statement instructs the Perl interpreter to look for a file called CGI.pm and load it into memory.

use CGI (":standard");

The modifier 'standard' makes all functions and variable defined as 'standard' in the CGI module accessible to the using script. use statements are commonly made at the beginning of a program or subroutine. This makes it easier to understand the program and see which modules are loaded.