Last updated on December 2nd, 2015 at 01:24 am

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

There are many methods in perl on how to send HTTP GET request and grab it on the targeted web page. Different modules are available which will allow us to get the requested variables easily. Here i am not going use any modules. Just a simple straight forward script for displaying or saving the HTTP GET request variable which was submitted from a HTML form.

If you are using modules then LWP::UserAgent is the best one.

Here is the form script

<form name="server" action="" method="GET">
Enter Your Name <input type="text" name="myname"/>
<input type="submit" value="Sumit"/>

This will be the perl script that grabs the name that you have entered on the form will look like this

#!/usr/local/bin/perl -w
use Net::OpenSSH;
use CGI qw(:standard);
print header;
my $buffer;
my $pair;
my $name;
my $value;
my $FORM;
my %FORM;
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
    if ($ENV{'REQUEST_METHOD'} eq "GET")
        $buffer = $ENV{'QUERY_STRING'};
    # Split information into name/value pairs
    my @pairs = split(/=/, $buffer);
my $name= $pairs[1];
print "My Name Is $name";

Please make sure you have changed the path of the interpreter in the script.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Leave a Reply

Your email address will not be published. Required fields are marked *