[Perl] Submit information to a form processor

Gaal Yahas gaal at forum2.org
Sun Jan 13 05:53:30 PST 2002


Georges,

On Sun, Jan 13, 2002 at 03:26:46PM +0200, Georges EL OJAIMI wrote:
> I have my script at http://www.mydomain.com/cgi-bin/form1.pl
> After parsing the input data in my program, I want to resubmit it to
> another form processor at http://www.anotherdomain.com/cgi-bin/form2.pl

Use the LWP module to make a HTTP request of your own, and use CGI to
thunk each of form1.pl's parameters into form2.pl. You will want
to put something like this in your first script (UNTESTED):

==snip==
use CGI qw(:common);
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);

$query = new CGI;

# ... (do stuff) ...

# make a new request to form2.pl
$ua = LWP::UserAgent->new;
my $req = POST 'http://www.anotherdomain.com/cgi-bin/form2.pl',
	[ map { $_ => param($_) } $query->param() ]; # thunks ALL parameters!

$res = $ua->request($req); # $res now has the output from form2.pl's 
==snip==

-- 
Gaal Yahas <gaal at forum2.org>
http://www.forum2.org/gaal/
http://www.livejournal.com/~gaal/



More information about the Perl mailing list