use strict; use warnings; use WWW::Mechanize; use HTTP::Cookies; use Data::Dumper; my $url = 'http://search.cpan.org'; my $searchstring = 'mechanize'; my $mech_obj = WWW::Mechanize->new(); $mech_obj->get( $url ); if( not $mech_obj->success() ) { print "Could not retrieve page:\n"; print $mech_obj->content(); die; } print "all forms:\n", Dumper( [ $mech_obj->forms ] ); $mech_obj->form_number( 1 ); $mech_obj->field( 'query' => $searchstring ); print "current form:\n", Dumper( $mech_obj->current_form() ); $mech_obj->submit(); print "content:\n", $mech_obj->content();