Dear Monks, I am very new to Perl, and I have looked all over for solutions and reasons why my code isn't working. I wanted to write a program that would get an anagram-finding website, plug in the user input, and return the anagrams. I have written this code:

#!/usr/bin/perl use strict; use diagnostics; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new(); print "What word would you like to know the anagrams of?\n"; my $word = <STDIN>; $word = chomp( $word ); $mech->get( 'http://www.wordsmith.org/anagram/index.html' ) or die "Un +able to access page.\n"; $mech->field( 'anagram', $word ); $mech->submit; wait until $mech->success(); print $mech->content;

I cannot remember all the different options that I have tried to fix the problem, but the latest one was:

 $mech->click_button(name => 'Get anagrams');

No matter what I put on line 14 (the submit line), there is a problem. There seems to be less of a problem when I just use "submit", in which case, Perl returns:

 I don't know which form to submit, sorry.

I have tried to do it by numbering the "submit" options, but to no avail. I just can't seem to submit the page. The source code for the page is:

<form action="anagram.cgi" name="inputform" onSubmit="return valid_in +put(anagram)"> <table border="0" bgcolor="#DDEEFF" bordercolor="#DDEEFF" cellpadding= +"8" cellspacing="0"> <tr> <td>Find anagrams for <input name="anagram" size="16" type="text">< +/td> <td><input value="Get anagrams" type="submit"><input name="t" value +="1000" type="hidden"><input name="a" value="n" type="hidden"></td> </tr>

Maybe I'm just in over my head, but I've been searching for days, and I would very much appreciate any help you could give. Thank you!

Joie


In reply to WWW::Mechanize::Firefox question by Joie

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.