http://www.perlmonks.org?node_id=32240

Q&A > CGI programming > How do post to a URL from a form and display the results in a browser? - Answer contributed by icuc

I think this , perhaps , could satisfy your need.
---------------------------

#!/user/local/bin/perl

use strict;
use CGI;
use HTTP::Request;
use LWP::UserAgent;

my $q = CGI->new();
$q->use_named_paramters(1);
my $var1 = $q->param('a');
my $var2 = $q->param('b');

my $ua = LWP::UserAgent->new();

my $method = "POST";
my $url = "http://where_you_want";

use HTTP::Header;
my $header = HTTP::Header->new();
my $content = "v1=".$var1."&v2=".$var2;
my $request = HTTP::Request->new($method, $url, $header, $content);

use HTTP::Response;
my $response = $ua->request($request);
if($response->is_success) {
print $response->content;
}
else {
print $response->error_as_HTML;
}
-------------------------------------
for more details, please check Perl's Documents HTTP::Request, HTTP::Header, HTTP::Response, LWP::UserAgent, etc.

  • Comment on Answer: How do post to a URL from a form and display the results in a browser?
Replies are listed 'Best First'.