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
-
#!/usr/bin/perl
-
#Script From Mistonline.in
-
use strict;
-
use CGI;
-
my $cgi = new CGI;
-
print
-
$cgi->header() .
-
$cgi->start_html( -title => ‘Cgi Query String Results‘) .
-
$cgi->h1(‘Values Passed’) . “\n“;
-
my @params = $cgi->param();
-
print ‘<table border=”1″ cellspacing=”0″ cellpadding=”0″>’ . “\n“;
-
foreach my $parameter (sort @params) {
-
print “<tr><th>$parameter</th><td>” . $cgi->param($parameter) . “</td></tr>\n“;
-
}
-
print “</table>\n“;
-
print $cgi->end_html . “\n“;
-
exit (0);
Related posts:












