No such thing as a small change | |
PerlMonks |
Re: How do post to a URL from a form and display the results in a browser?by icuc (Initiate) |
on Sep 13, 2000 at 07:15 UTC ( [id://32240]=note: print w/replies, xml ) | Need Help?? |
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.
In Section
Seekers of Perl Wisdom
|
|