Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How do I iterate through this data set?

by 7stud (Deacon)
on May 21, 2011 at 20:28 UTC ( [id://906093]=note: print w/replies, xml ) Need Help??


in reply to How do I iterate through this data set?

You have this hash:

{ item => [ ... ... }

Immediately following the arrow is a bracket, and a bracket is the syntax for an array reference. So when you use the 'item' key to get its corresponding value, you get an array reference back. You are are treating the array reference as a hash reference.

Looking at the original data, the array has a bunch of hash references for elements. Hash references are denoted by braces: {...}

I would rename the variable in Corion's loop to help you keep track of what type you are getting out of the array:

for my $href (@{ $hash->{'searchResult'}->{'item'} }) { ... }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://906093]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-24 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found