In Perl, Common Gateway Interface (CGI) is nothing more than a protocol which defines the interaction of web servers with some executable programs in order to produce dynamic web pages. Basically, it shows how the web server sends information to the program and the program sends the information back to the web server which in turn can be sent back to the browser.
POST are not interchangeable and both the types are different. Proxy servers may cache the output of
GET method is the default method for all web request to pass the information from browser to the web server and it also creates a long string that shows up in the browser’s URL box. It sends the encrypted user information attached to the page request. The page and the encrypted information is separated by ? character:
This information is passed through
QUERY_STRING header and by using
QUERY_STRING environment variable it can be easily accessed in your CGI program. Only 1024 characters can be there in a request string as the
GET method has the size limitation. Information can be passed by simply concatenating key-value pairs along with any URL.
NOTE: If you are dealing with passwords or any other sensitive information in order to pass it to the server, then using the
GETmethod is not a good choice.
Perl-CGI script for the above GET method form:
As shown above, in the output image, the information is passed along with the URL:
In contrast, the
POST method is the most reliable method to pass information to a CGI program. Generally, the
POST method is used when the information is required to be uploaded on the server. Aiming of uploading larger amount of data,
POST method is considered more suitable for it instead of
GET method as none of the data appears in the URL box. Similar to the
GET method, the information is packed in this too but instead of sending it as a text string after ? in the URL box, it sends it as a separate message to the server through a different route which is accessible by your Perl/CGI program.
Perl-CGI script for the above POST method:
As it can be seen in the image above, that after using
POST method the information is uploaded to the server without appearing into the URL box. This makes data sent over the internet, more secure in comparison to the
- Perl | Basic Syntax of a Perl Program
- jQuery | post() Method
- How to receive JSON POST with PHP
- How to display bootstrap carousel with three post in each slide?
- How to select and upload multiple files with HTML and PHP, using HTTP POST?
- Perl vs C/C++
- Perl vs Python
- Perl | eq operator
- Perl | ne operator
- Perl | tell() Function
- Perl | last in loop
- Perl | tr Operator
- Perl | CGI Programming
- Perl Hash
- Perl | References
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.