How to get the query string value in perl cgi script
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:
- How to run a SQL query in phpMyAdmin
- How to run CGI or Perl Scripts in IBM Http Server [IHS] or Apache Servers
- Replacing a string using php
- Appending string using php to a text file
- Javascript Events A Complete Video Tutorial With Yahoo
- The thrilling potential of sixth sense technology
- Embedding youtube video in wordpress
