Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello All, I need help! I'm totally confused. I'm trying to access and list the forms available on a page using WWW::Mechanize::Firefox
$mech->get("http://www.w3schools.com/html/html_forms.asp"); my @forms = $mech->forms(); my $form_obj ; while ( ($index, $form_obj) = each @forms) { print "[F$index] : ", $form_obj , "\n"; print Dumper ($form_obj), "\n"; }
# The $form_obj that is returned is a MozRepl::RemoteObject::Instance # When i do a print Dumper on it, i can't see anything remotely useful. Everything appears to be describing the connection to Firefox, and i can't see anything to do with a form. What I'm trying to do is print a list of forms available on a page and then allow the user to select the form in order to input some data. I've tried googling for some examples of forms with Mechanize::Firefox and MozRepl::RemoteOjects but what i found was neither clear nor well explained. Any assistance would be greatly appreciated

Replies are listed 'Best First'.
Re: Accessing Forms with WWW::Mechanize::Firefox
by choroba (Cardinal) on Jul 12, 2013 at 17:51 UTC
    Something like the following?
    while ( my ($index, $form_obj) = each @forms) { print join ' ', "[F$index] :", keys %{ $form_obj->getElementsByTag +Name('input') }, "\n"; }

    I did not find it in the documentation, but by trial and error. But maybe I do not know where to look.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ