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

for this example:

use HTML::Form; $v="http://search.cpan.org"; $uv=""; $form = HTML::Form->parse($uv, $v); if (defined($form)) {print $form->dump;}else {print "form is undefined\n";} exit 0;

always yields "form is undefined".
q1. what should the first argument in parse() be set to? Can't find it in the doc.
q2. Will setting this value properly define $form? If not, what will?

Thank you.

20050216 Janitored by Corion: Added code tags

2005-02-16 Edited by Arunbear: Changed title from 'html::form', as per Monastery guidelines

Replies are listed 'Best First'.
Re: How to use HTML::Form
by moot (Chaplain) on Feb 16, 2005 at 03:29 UTC
    From perldoc HTML::Form:
    @forms = HTML::Form->parse( $html_document, $base_uri ) @forms = HTML::Form->parse( $response ) The parse() class method will parse an HTML document and build up "HTML::Form" objects for each <form> ele­ ment found. If called in scalar context only returns the first <form>. Returns an empty list if there are no forms to be found.
    Looks like the first argument should be something containing html.

    HTML::Form::parse returns an array in list context or the first form in scalar context. Since you don't have any forms to parse, the first form is undefined, so the answer to q2 is "probably".

Re: How to use HTML::Form
by PodMaster (Abbot) on Feb 16, 2005 at 03:37 UTC
    q1. what should the first argument in parse() be set to? Can't find it in the doc.
    How is that possible?
    q2. Will setting this value properly define $form? If not, what will?
    What are you trying to do?

    The documentation for HTML::Form is here, I suggest you RTFM.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: How to use HTML::Form
by anykey (Initiate) on Feb 16, 2005 at 14:52 UTC

    Clarification: When I said "can't find it in the doc", I didn't mean I could not find the doc. I meant I read the doc and did not find an explanation or example that explained how to set the content of arg1.

    So, comments like RTFM are worthless to me and anyone else reading this q&a seeking advice and clarification.

    This is just a snippet. The simple question "What are you trying to do?" renders the simple reply "To fill & submit a html form." As an example, let's say I'm tyring to fill the search string for the search.cpan.org page and retrieve results.