I use a function in many perl scripts that will submit a form.
It works very well. *Except for when you try to submit a form where the URL has a hyphen (-) in it.
Why is that? Does anyone know?
Here is the function I use to submit a form.
sub submit_form {
print "Content-type: text/html\n\n";
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
my $req = POST 'http://www.domain-name.com/cgi-bin/script.pl',
[ first_name => $firstname, email => $email];
$content = $ua->request($req)->as_string;
print "content = $content";
}
It works great. But, notice how the URL is "domain-name"?
For some reason, it doesn't like this. If the URL is "domainname", it works.
I've tried placing an escape "\" character before it.
If anyone has *any* ideas I would be very grateful.
Thank you
Eric Reynolds
[perl]
use LWP::UserAgent;
$ua = new LWP::UserAgent;
my $req = new HTTP::Request 'POST','http://www.domain-name.com/cgi-bin/script.pl';
$req->content_type('application/x-www-form-urlencoded');
$req->content('first_name=$firstname&email=$email');
my $content = $ua->request($req)->as_string;
[/perl]
(If you do it this way you'll have to use URI::Escape on the parameters you're passing)