Date: | Mon, 16 Sep 2002 11:38:44 +1000 |
From: | Iain Truskett <spoon [...] cpan.org> |
To: | www-mechanize [...] rt.cpan.org |
Subject: | a subclass |
package Subclass;
use base 'WWW::Mechanize';
use HTTP::Cookies;
sub new
{
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->cookie_jar(HTTP::Cookies->new(
file => 'cookies.txt',
autosave => 1,
ignore_discard => 1,
));
return bless $self, $class;
}
sub field {
my ($self, $name, $value, $number) = @_;
$number ||= 1;
my $form = $self->{form};
if ($number > 1) {
$form->find_input($name, $number)->value(
(defined $value ? ($value) : ())
);
} else {
$form->value($name, (defined $value ? ($value) : ()));
}
}
1;