#!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize; my $ua = WWW::Mechanize->new(); use URI::file; $ua->get( URI::file->new( __FILE__ )->abs(URI::file->cwd) ); #~ $ua->get( 'file:'. __FILE__ ); $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); $ua->timeout( 1 ); $ua->update_html( <<'HTML','.');## $ua->{content} = <<'HTML'; localhost form
HTML my $form = $ua->form_number( 0 ); $form->action( $form->action . 'THE_NEW_ACTION/' ); $ua->submit; __END__ $ perl mechanize.inline.form.action.pl POST http://localhost/THE_NEW_ACTION/ Accept-Encoding: gzip Referer: file:mechanize.inline.form.action.pl User-Agent: WWW-Mechanize/1.71 Content-Length: 0 Content-Type: application/x-www-form-urlencoded (no content) 500 Can't connect to localhost:80 (timeout) Content-Type: text/plain Client-Date: Sun, 08 Jan 2012 21:03:56 GMT Client-Warning: Internal response Can't connect to localhost:80 (timeout)\n LWP::Protocol::http::Socket: connect: timeout at C:/perl/site/5.14.1/lib/LWP/Protocol/http.pm line 51.\n Error POSTing http://localhost/THE_NEW_ACTION/: Can't connect to localhost:80 (timeout) at mechanize.inline.form.action.pl line 39