Perl Home Search CGI

2.2 CGI POST method


14.02.2006

2.1 CGI GET method [  up  ] - [ top ] 2.3 https XML POST with LWP

  • use LWP::UserAgent;
  • use HTTP::Request::Common;

my $ua = LWP::UserAgent->new(agent => 'Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)');

my %tags = ();
$tags{'action'} = 'my action value';
$tags{'id'    } = 'my id value';

my $resp = $ua->request(
	POST 'http://yourdomain.com/cgi-bin/script.pl' ,
                Content_Type  => 'form-data', # or application/x-www-form-urlencoded
                Content       => [ %tags ]
);
        
print $resp->error_as_HTML unless $resp->is_success;

print $resp->content();

copyright by reto - created with mytexi