If I may add a suggestion, you should look at using HTTP::Request::Common to simplify this code.
HTTP::Request::Common has a routine called POST, which does almost the same thing as what you are doing with HTTP::Request, only in less steps.
Using these two modules your code changes to something like this:
#!/usr/bin/perl -w use strict; use URI; use HTTP::Request::Common qw(POST); use LWP::UserAgent; my $username = 'username'; my $password = 'password'; my $subject = 'subject'; my $comments = 'comment'; my $post = 'post'; my $url = 'http://www.somesite.com'; my $ua = LWP::UserAgent->new; my $result = $ua->request(POST $url, [ id => '20010131', username => $username, password => $password, subject => $subject, comments => $post, submit => 'Submit', ]); print $result->as_string; __END__
In reply to Re: LWP posting a form
by dkubb
in thread LWP posting a form
by Kickstart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |