I'm new to Perl and so far in my reading-a-book-to-learn-perl learning process its good until i encountered this CGI thing. What does it do?
Can anyone site a good example where CGI is used in Perl.
I'm new to Perl and so far in my reading-a-book-to-learn-perl learning process its good until i encountered this CGI thing. What does it do?
Can anyone site a good example where CGI is used in Perl.
CGI, the Common Gateway Interface, is an interface used by web servers to relay requests to other programs so they can generate or locate content to send to the client.
It could also refer to the module with the same name.
As other have told you, CGI is an internet protocol. It defines a mechanism for creating dynamic content on a web site. Programs that make use of this protocol are known as CGI programs (or, more loosely, just "CGIs").
You can write CGI programs in pretty much any programming language. When the CGI protocol became popular (in the second half of the 1990s) Perl was one of the most popular languages used.
So in Perl, a CGI program is simply a program which is written to follow the CGI protocol. Practically, that means that it might parse some parameters out of an HTTP request, carry out some processing and then build an HTTP response which the web server will return to the requesting browser.
For example, you might have a database that is accessible from web page. The user visits a web page and enters some search terms. The CGI program will take those search terms and build a web page containing some data found in the database. This is the basis of a web site like Amazon.
So you would write a CGI program in Perl if you wanted to build a dynamic web site using Perl. Well, you would have done if you were doing that ten years ago. These days, you'd be far better advised to use a framework like Dancer or Catalyst which are built on the PSGI protocol.