in reply to Help with forms

Too vague? Nonesense!

I'm trying to simulate the action of clicking the "Submit" button

Simple: use LWP::Simple

say you have a CGI script like this (called foo.cgi):

#!/usr/bin/perl use strict; use CGI; my $cgi = new CGI; print $cgi->header; if (my $foo = $cgi->param('foo')) { print "foo = $foo"; } else { print "nothing special"; }
all this script does is check for a parameter named 'foo' - if found, print it's value, otherwise print some default message.

If you create an HTML document that contains a form that points to this script, and include a text box named 'foo' and a submit button - then when the user clicks the submit button, the value of 'foo' is sent to the script.

So, to automate this behaviour in a Perl script, you can either roll out your own socket code, or be cool and use the LWP::Simple CPAN module - which by the way, is not the only module for such a purpose (check out LWP::UserAgent for more advanced control).

Here is the simple web bot:

#!/usr/bin/perl -w use strict; use LWP::Simple; print "with no arguments: "; print get('http://localhost/cgi-bin/foo.cgi'), "\n"; print "with arguments: "; print get('http://localhost/cgi-bin/foo.cgi?foo=bar'), "\n";
And that's it.

Jeff

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)