
February 27th, 2013, 12:41 PM
|
 |
!~ /m$/
|
|
Join Date: May 2004
Location: Reno, NV
|
|
I expect that you can drop most of the arrows.
Code:
foreach my $id (keys %{$xml->{children}{content}}) {
print($xml->{children}{content}{$id}{title}."\n");
}
When you have a reference, only the first arrow is necessary.
Also, this might not be helpful, but when you are reaching into such deeply nested structures, and the thing you want to work with isn't the key, you can pull out just the hash or element you want to work with.
Example:
Code:
foreach my $content (values %{$xml->{children}{content}}) {
print($content->{title}."\n");
}
By asking for the value, you can put that into a variable and have a direct reference to the hash you need to work with without having to reference the entire structure each time.
|