# This works fine. Here I get the form. $form=_get_new_form($self,$response->as_string,$response->base); if($form==0) { return 0; } # Here I am filling out the form. foreach $input ($form->inputs) { if($input->name eq "email") { $form->value($input->name,$email); } if($input->name eq "clientCertReq") { $form->value($input->name,$file); } } #Here is where the problem is. $response=$agent->request($form->click("submit")); if(!$response->is_success) { $ERROR=$response->error_as_html; return 0; } return 1; } sub _get_new_form { my ($self,$html,$uri,$form)=@_; $form=HTML::Form->parse($html,$uri); if(!defined ($form)) { return 0; } return $form; } }