foreach my $form ($mech->forms()) { if ($form->find_input("fieldname") { do_stuff(); } }