in reply to Re^2: Parsing SOAP::Lite results
in thread Parsing SOAP::Lite results
I tested that code before posting. I changed $VAR1 to my $getToysResults but otherwise left the Dumper output unchanged. Here's the script (pm_parse_soap_hash.pl) in its entirety:
#!/usr/bin/env perl use strict; use warnings; my $getToysResults = { 'Toys' => bless( { 'Toy' => [ bless( { 'ToyLocations' => bless( { 'ToyLocation' => [ { 'toyQuantity' => '1', 'locationName' => 'toybox' }, { 'toyQuantity' => '4', 'locationName' => 'shelf' } ] }, 'ArrayOfToyLocation' ), 'color' => 'none', 'toyName' => 'Sorry', 'size' => 'medium' }, 'Board' ) ] }, 'ArrayOfToy' ) }; 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"; } }
Here's the output:
$ pm_parse_soap_hash.pl toybox shelf
Try running that script. If it works, then maybe the data you posted was incorrect (typo, cut-and-paste error, etc.) or perhaps you used my code differently. Try adding print Dumper $getToysResults; just before the outer foreach in your code and see if it produces the same output as you originally posted.
If it doesn't work, please post full output along with your Perl version and OS: as it stands, I can't see anything there that wouldn't work on any version of Perl 5.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Parsing SOAP::Lite results
by Roboz (Novice) on Sep 28, 2012 at 12:52 UTC | |
by kcott (Archbishop) on Sep 28, 2012 at 13:21 UTC | |
by Roboz (Novice) on Sep 28, 2012 at 13:44 UTC | |
by kcott (Archbishop) on Sep 28, 2012 at 15:13 UTC | |
by Anonymous Monk on Sep 28, 2012 at 12:57 UTC |