download with HTML::FORM login and password on page




hi,

i don't understand my code is corrupted at form "value" instance??
error prompt : Can't call method "value" on an undefined value at
ligne 27 (here : $form->find_input('txtusername')-
value($user);) ??

any ideas, thanks

#!/usr/bin/perl -w

use strict;
use warnings;
use LWP::UserAgent;
use HTML::Form;

my ($user,$pass ) = qw(username password);
my $base = 'http://www.mysite/login.asp/';

my $ua = LWP::UserAgent->new(agent => 'Microsoft Internet Explorer
6.0' );

my $req = HTTP::Request->new( GET => "${base}" );

my $res = $ua->request($req);
die $res->status_line if not $res->is_success;

my $form = (HTML::Form->parse($res->content, $base))[1];

$form->find_input('txtusername')->value($user);
$form->find_input('txtpassword')->value($pass);

$ua->request($form->click );
.