CGI - Handle Common Gateway Interface requests and responses | Search for a title, author or keyword | ||||||||
CGI - Handle Common Gateway Interface requests and responses CGI.pm is a Perl module. Perl modules are pieces of code that you can use in your program to do a job that's been done before. Half of learning how to script Perl successfully is knowing how to write the code. The other half is knowing when NOT to write the code. Or, to be more exact, knowing when to take advantage of the built-in Perl functions or when to use libraries and modules that other people have written to make your programming life easier. Why reinvent the wheel? CGI.pm is a stable, complete and mature solution for processing and preparing HTTP requests and responses. Major features including processing form submissions, file uploads, reading and writing cookies, query string generation and manipulation, and processing and preparing HTTP headers. Some HTML generation utilities are included as well. It has the benefit of having developed and refined over 10 years with input from dozens of contributors and being deployed on thousands of websites. CGI.pm has been included in the Perl distribution since Perl 5.4, and has become a de-facto standard, and also comes with built-in support for mod_perl and mod_perl2 as well as FastCGI. There are two styles of programming with CGI.pm, an object-oriented style and a function-oriented style. In the object-oriented style you create one or more CGI objects and then use object methods to create the various elements of the page. In the function-oriented style, there is one default CGI object that you rarely deal with directly. Instead you just call functions to retrieve CGI parameters, create HTML tags, manage cookies, and so on. This provides you with a cleaner programming interface, but limits you to using one CGI object at a time. The examples in this document mainly use the object-oriented style. Because CGI.pm is so large, some people consider it bloated and complain that it wastes memory. In fact, it uses many creative ways to increase its efficiency including a custom implementation. This means that it loads only code that you need. If you use CGI.pm only to parse input, but do not use it to produce HTML, then CGI.pm does not load the code for producing HTML: use CGI qw(:cgi). The :cgi import tag imports all CGI-handling methods, such as param(), path_info() and the like, excluding all methods that generate HTML standard elements.
|
|||||||||
CGI - Handle Common Gateway Interface requests and responses | Disclaimer: this link points to content provided by other sites. |