Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How do I iterate through this data set?

by 7stud (Deacon)
on May 21, 2011 at 20:28 UTC ( #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
Node Status?
node history
Node Type: note [id://906093]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-02-23 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (310 votes). Check out past polls.

    Notices?