use WWW::Mechanize; my $fh = FileHandle->new("text.txt", "w"); my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->get("xxx"); $mech->mirror( $mech->find_image(url_regex => qr/captcha/)->url_abs, "tokei.jpg" ); $mech->get("xxx"); print "type:"; my $cap = ; $mech->form_id( 'UserLoginForm' ); $mech->field( "data[User][username]", "xxx" ); $mech->field( "data[User][password]", "xxx" ); $mech->field( "captcha", $cap ); $mech->submit(); sleep (3); $mech->get("xxx", ':content_file' => "r.htm"); $mech->dump_text( $fh ); $fh->close;