Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Accessing/Printing Complex Data Structure

by graff (Chancellor)
on Apr 12, 2003 at 03:19 UTC ( #250019=note: print w/replies, xml ) Need Help??


in reply to Accessing/Printing Complex Data Structure

Given this bit of your code (note: indenting helps):
foreach my $img ( sort keys %images ) { foreach ( @{$images{$img}} ) { # this is line 11 ...
and this bit of output from Data::Dumper:
'intra-d_1050044970' => { 'frags' => [ ....
The problem is that your second "foreach" is treating the content of "$images{$img}" as a reference to an array, when it is actually a reference to a hash (and the first key of that hash, as shown by Dumper, is 'frags'). The code should have been:
foreach my $img ( keys %images ) { foreach my $typ ( keys %{$images{$img}} ) { ... # next layer -- content of $images{$img}{$typ} -- depends o +n value of $typ: ... # 'frac' has AoAoH ... # others have just a hash
Hope that helps.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2023-01-30 23:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?