#!/usr/bin/perl --
use strict;
use warnings;
use WWW::Mechanize 1.66;
use URI::file;
Main( @ARGV );
exit( 0 );
sub Main {
my $ua = WWW::Mechanize->new( autocheck => 1, );
$ua->timeout(0.00000000001);
$ua->get( URI::file->new(__FILE__)->abs( URI::file->cwd ) );
$ua->update_html( <<'HTML' );
test.html : localhost form
HTML
print $ua->dump_forms,"\n\n";
$ua->set_fields( qw' r1 three r2 three r3 three ');
print $ua->dump_forms,"\n\n";
$ua->set_fields( qw' r2 7 ');
print $ua->dump_forms,"\n\n";
$ua->add_header( Referer => undef );
$ua->add_handler(
"request_send",
sub { $_[0]->dump; return; },
m_method => 'POST'
);
$ua->submit(0);
$ua->delete_header( 'Referer' );
}
__END__
$ perl mechanize.radio.pl
POST http://localhost/
r0=0 (hidden disabled readonly)
r1= (radio) [-1/one|2/two|3/three]
r2= (radio) [1/one|-2/two|3/three]
= (submit)
POST http://localhost/
r0=0 (hidden disabled readonly)
r1=3 (radio) [-1/one|2/two|*3/three]
r2=3 (radio) [1/one|-2/two|*3/three]
= (submit)
r3=three (text)
POST http://localhost/
r0=0 (hidden disabled readonly)
r1=3 (radio) [-1/one|2/two|*3/three]
r2=7 (radio) [1/one|-2/two|:3/three]
= (submit)
r3=three (text)
POST http://localhost/
Accept-Encoding: gzip
User-Agent: WWW-Mechanize/1.66
Content-Length: 18
Content-Type: application/x-www-form-urlencoded
r1=3&r2=7&r3=three
Error POSTing http://localhost/: Can't connect to localhost:80 (timeout) at mechanize.radio.pl line 63