I'm trying to create a program, that when sent a private message is a chat pane, responds. I've figured out the logic to parse for private messages, but I've been having some trouble responding. Here's my code, and the HTMl for the form I'm trying to fill.

$mech->form_name("chatform"); $mech->set_fields( graf => '/msg stinkbank success' ); print $mech->current_form()->dump(); $mech->current_form()->click(); #$mech->click_button( value => "Chat");
<form name=chatform onSubmit='return false;'> <div id="InputForm" class=inputform> <Center> <input style="width: 70%;" maxlength=200 class=text type=text size=12 +name=graf onKeyUp='checkforenter(event);' autocomplete="off"> <input class=button type=button onClick="submitchat()" value="Chat"> </center> </div> </form>

The output from my dump is:

GET http://www7.kingdomofloathing.com/lchat.php [chatform] graf=/msg stinkbank success (text) <NONAME>=Chat (button)

So I know the field is being filled, but the message is not being displayed, which means submitchat() is not being called. When I comment out click() and use $mech->click_button() instead I get the following error: "Can't call method "header" on an undefined value at C:/Perl/lib/WWW/Mechanize.pm line 2381".

I guessing that click() isn't working because it searches for input of type 'submit' or maybe because clickevent is a function in the file not just making a request to server, but I don't know why I'm getting this error with click_button()

My goal is obviously to make submitchat() run while my msg is in the text field. What am I doing wrong? How can I accomplish this?


In reply to Difficulties with WWW::Mechanize ->click_button() difficulties by jdetloff

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.