G'day Roboz,
You effectively have arrays nested within arrays, so you'll need some sort of nested loops to read the data.
If you change
foreach my $e (@{$getToysResults->{Toys}{Toy}}){ print "$e->{ToyLocations}{ToyLocation}{locationName}\n"; }
to
foreach my $e (@{$getToysResults->{Toys}{Toy}}) { my $location_array_ref = $e->{ToyLocations}{ToyLocation}; for my $location_array_hash_ref (@$location_array_ref) { print $location_array_hash_ref->{locationName}, "\n"; } }
you'll get the results you're after.
[Aside: On first viewing, I found your naming conventions somewhat counter-intuitive: Toys and ToyLocations are both plural but point to single objects; Toy and ToyLocation are both singular but point to (potentially) multiple objects. In the context of the Dumper output, it's fairly easy to see what's intended; in isolation, those names may easily lead to problems of misinterpretation (particularly if you or someone else revisits the code 12 months down the track).]
-- Ken
In reply to Re: Parsing SOAP::Lite results
by kcott
in thread Parsing SOAP::Lite results
by Roboz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |