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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |