Update: I looked closer at your code and the first issue is that you're never sending the filled out form back to the server:
# Update Form
$forms[1]->click("update");
Use something like the following code, as suggested by the HTML::Form documentation:
my $filled_out_request = $forms[1]->click;
print $filled_out_request->as_string; # for debugging, see below
$response = $ua->request($filled_out_request);
Whenever automating access to a webpage, it is most important to replicate what the browser is sending. There are many tools nowadays to do that:
- HTTP::Recorder - it is a proxy that sits between your browser and the web and it will create a WWW::Mechanize script that replicates all your actions.
- For Mozilla there is the Live HTTP Headers extension, which displays all data that is sent in a log file against which you can compare your programs output
- My own module, Sniffer::HTTP, which also can display all HTTP traffic as it gets sent and received.
With any of these tools, the process is always to
- Get the original data sent by the browser
- Write a program to replicate it
- Compare the data sent by your program against the original data
- Repeat
Of course, I, as the author, think that my tools (Sniffer::HTTP and HTTP::Request::FromTemplate) are superior, but I use the other tools as well.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.