CGI is a simple protocol used to communicate between Web forms and your program. A CGI script can be written in any language that can read STDIN, write to STDOUT, and read environment variables. This includes virtually any programming language, including C, Perl, or even shell scripting.
The following sites are excellent sources for writing CGI scripts: