How to get the query string value in perl cgi script

This Tutorial Has Been Viewed 3,381 Times.

In this tutorial we will see how to get the query string value using very simple perl CGI script.

When we hit a URL from the web browser with a query string say

http://mistonline.in/cgi/data.cgi?program=php

In which program=php is the query passed.Now we will see how we get the same value using perl CGI script.

Here is the code

  1. #!/usr/bin/perl
  2. #Script From Mistonline.in
  3. use strict;
  4. use CGI;
  5. my $cgi = new CGI;
  6. print
  7. $cgi->header() .
  8. $cgi->start_html( -title => Cgi Query String Results) .
  9. $cgi->h1(‘Values Passed’) . \n;
  10. my @params = $cgi->param();
  11. print ‘<table border=”1″ cellspacing=”0″ cellpadding=”0″>’ . \n;
  12. foreach my $parameter (sort @params) {
  13. print “<tr><th>$parameter</th><td>” . $cgi->param($parameter) . “</td></tr>\n;
  14. }
  15. print “</table>\n;
  16. print $cgi->end_html . \n;
  17. exit (0);
VN:F [1.9.13_1145]
Rating: 4.0/10 (2 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 2 votes)

How to get the query string value in perl cgi script, 4.0 out of 10 based on 2 ratings

Incoming search terms:





You will also be interested in ,

Tags:

Leave a Reply

Spam protection by WP Captcha-Free

Proudly designed by Mistonline.in.
Affordable Seo PackagesSeo BlogEdu Backlinks
More in perl (13 of 14 articles)