Recent Posts

This Post Has Been Viewed 198 Times.

How to get the query string value in perl cgi script

Posted by admin | Posted in perl | Posted on 03-02-2010

0

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.5.7_846]
Rating: 0.0/10 (0 votes cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • Xerpi

Related posts:

  1. How to run a SQL query in phpMyAdmin
  2. How to run CGI or Perl Scripts in IBM Http Server [IHS] or Apache Servers
  3. Replacing a string using php
  4. Simple Pagination Using PHP Script
  5. Appending string using php to a text file
  6. Simple PHP Login Script

Write a comment

Spam Protected