Hey all, I feel silly for not being able to figure out what I'm doing wrong... but here it is...
I've got this code and I'm trying to get all of the form values... specifically, the INPUT names and values. The problem is, when I run it, it gives me an array for the input values and I can't seem to get anything out of the array except for: ARRAY(0x1d9d144)
Can someone explain to me, are the numbers a memory address?
And... what can I do to get the values in the array?
#!/usr/bin/perl -w
#use strict;
use LWP::Simple;
use WWW::Mechanize;
use HTML::Form;
my $ua = LWP::UserAgent->new;
my $response = $ua->get("http://www.ncbi.nlm.nih.gov/sites/entrez?
+term=rnr2&cmd=Search&db=nuccore&QueryKey=17");
my @forms = HTML::Form->parse($response);
foreach $item(@forms){
#print $item."\n";
while( my ($k, $v) = each %$item ) {
#print "key: $k, value: $v.\n";
if ($k eq "action"){
$action = $v;
print "\n\n"."ACTION: ".$action."\n";
}
if ($k eq "method"){
$method = $v;
print "\n\n"."METHOD: ".$method."\n";
}
if ($k eq "attr") {
print "\n\n"."ATTRIBUTES"."\n";
while( my ($k, $v) = each %$v ) {
print "key: $k, value: $v.\n";
}
}
if ($k eq "inputs"){
print "\n\n"."INPUTS"."\n";
@newarray = $v;
foreach $thisItem(@newarray){
print $thisItem."\n";
}
}
}
}
UPDATE - I changed @newarray = $v; to @newarray = @$v; and it works. Now I have a boatload of hashes to go through! Thanks to thezip for helping me out!
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.