use strict; use WWW::Mechanize; use WWW::Mechanize::FormFiller; use URI::URL; my $agent = WWW::Mechanize->new( autocheck => 1 ); my $formfiller = WWW::Mechanize::FormFiller->new(); $agent->env_proxy(); $agent->follow('http://use.perl.org/'); $agent->get('http://use.perl.org/'); $agent->form(1) if $agent->forms and scalar @{$agent->forms}; $agent->form_number(2); { local $^W; $agent->current_form->value('query', 'WWW::Mechanize'); }; $agent->submit(); __END__ C:\>perl -MWWW::Mechanize -e"die WWW::Mechanize->VERSION" 1.11_01 at -e line 1. C:\>perl -MWWW::Mechanize::Shell -e shell Module File::Modified not found. Automatic reloading disabled. SetConsoleMode failed, LastError=|6| at C:/Perl/site/lib/Term/ReadKey.pm line 268. >open http://use.perl.org/ Use of uninitialized value in concatenation (.) or string at C:/Perl/site/lib/WWW/Mechanize.pm line 1743, line 1. Can't find any link matching http://use.perl.org/ on this page () at C:/Perl/site/lib/WWW/Mechanize/Shell.pm line 1028 Can't call method "code" on an undefined value at C:/Perl/site/lib/WWW/Mechanize/Shell.pm line 1034, line 1. >get http://use.perl.org/ Retrieving http://use.perl.org/(200) http://use.perl.org/> http://use.perl.org/> http://use.perl.org/>forms Form [1] GET http://use.perl.org/search.pl query= (text) = Go (submit) Form [2] GET http://search.cpan.org/search mode=module (option) [*module/Module|dist/Distribution|author/Author|doc/Documentation] query= (text) =Search (submit) Form [3] POST http://use.perl.org/login.pl unickname= (text) returnto=//use.perl.org/ (hidden readonly) op=userlogin (hidden readonly) upasswd= (password) login_temp= (checkbox) [*/off|yes/Public Terminal] userlogin=Log in (submit) http://use.perl.org/>form 2 GET http://search.cpan.org/search mode=module (option) [*module/Module|dist/Distribution|author/Author|doc/Documentation] query= (text) =Search (submit) http://use.perl.org/>value query WWW::Mechanize http://use.perl.org/>submit 200 http://search.cpan.org/search?mode=module&query=WWW%3A%3AMechanize> http://search.cpan.org/search?mode=module&query=WWW%3A%3AMechanize> http://search.cpan.org/search?mode=module&query=WWW%3A%3AMechanize>script foo.pl