CGI stands for "Common Gateway Interface." CGI scripts are written to take advantage of the common gateway interface. Scripts can be written in a variety of languages, although Perl is quite common.
When a visitor performs a “submit” on a webpage (e.g. subscribing to a newsletter and clicking submit), the form information is passed through a common gateway interface. Acting like mini programs, scripts help make these functions work because they are already prewritten to handle specific tasks.