Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://906093]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2018-05-26 12:53 GMT
Find Nodes?
    Voting Booth?