Hi all,

I had made an attempt to use WWW::Mechanize module using the following code.

In the below code, yes.html contains two field say UserId and Passwd and action for the form is login.cgi. If i use the following code , getting result a "blank" page. While looking into the error_log file, shows the error as
There is no form numbered 1 at /usr/pweb/phonekerala/cgi-bin/thisis.pl + line 26 Can't call method "value" on an undefined value at /usr/lib/perl5/site +_perl/5.6.0/WWW/Mechanize.pm line 409.

How can i get the display page using these parameters?

After running the program i should modify the code to integrate click function etc. So please help me to provide a solution to my above said problem.

Thanks

Code ..... Getting result page as blank.........
#!/usr/bin/perl print "Content-type: text/html\n\n"; use warnings; use strict; use WWW::Mechanize; use CGI; my $cgi = CGI->new(); my $form = $cgi->Vars; my $agent = WWW::Mechanize->new(); $agent->get('http:/mydomain.com/html/yes.html'); $agent->form_number('1'); $form->{UserId}='test01'; $form->{Passwd} = 's'; $agent->field('UserId',$form->{UserId}); $agent->field('Passwd',$form->{Passwd}); $agent->submit(); $agent->get('http://mydomain.com/cg-bin/login.cgi?UserId='.$form-> +{UserId}.'&Passwd='.$form->{Passwd}); print $agent->content();

20030704 Edit by Corion: Added formatting


In reply to Getting result page using WWW::Mechanize by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.