CPAN::Forum
Can't call method
| Posted on 2009-11-18 13:58:18-08 by rvbperl |
| Can't call method |
|
Hello,
I use perl 5.10 and WWW-Mechanize 1.60 module.
My perl script contains this portion of code :
# website
my ( $user, $pass ) = qw( toto lulu);
my $token = encode_base64("$user:$pass");
my $url = 'http://url';
# File to be uploaded
my $file="file.txt";
# agent initialization
my $mech = WWW::Mechanize->new();
$mech->add_header(Authorization => "Basic $token" );
# request
my $res = $mech->get($url);
# Upload file
$mech->field(monfichier => $file);
$mech->submit();
And when I launch the script, I've got the following error :
Can't call method "value" on an undefined value at /usr/local/lib/perl5/site_perl/5.10.0/WWW/Mechanize.pm line 1348.
It seems that I don't use correctly the field form ?
sub field {
my ($self, $name, $value, $number) = @_;
$number ||= 1;
my $form = $self->{form};
if ($number > 1) {
$form->find_input($name, undef, $number)->value($value);
}
else {
if ( ref($value) eq 'ARRAY' ) {
$form->param($name, $value);
}
else {
$form->value($name => $value); #Line 1348
}
}
}
Sombody could help me please ?
Thank's in advance
Herve |
| Direct Responses: Write a response |
See also World Wide Perl Training