I'm trying to create a hash of form fields and values using HTML::Form. Note from the code below that I'm using the LWP content method to fetch the form.
The relevant code is:
use HTML::Form;
my $form = HTML::Form->parse($response->content, $targetURL);
map $fields{$_} = $form->value($_), $form->inputs;
When I run this code I get the error message:
No such field 'HTML::Form::TextInput=HASH(0xa02cd30)'
When I supply a list of field names in place of $form->inputs everything works as expected.
When I try dereferencing $form->inputs I get the error message:
Can't use string ("31") as a HASH ref while "strict refs" in use or Can't use string ("31") as an ARRAY ref while "strict refs" in use (depending on whether I dereference $form->inputs as a hash or as an array).
The Perl HTML::Form documentation describes the inputs method as follows:
$form->inputs
This method returns the list of inputs in the form.
Any idea what the problem is?
I've got a work around using HTML::TokeParser but I'd rather learn why I can't get the inputs method to return a list I can use in my code.
Thanks! Mutant solved my problem. Another step along the path of figuring out object oriented programming!
-- Chris
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.