Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Parsing SOAP::Lite results

by Anonymous Monk
on Sep 28, 2012 at 10:32 UTC ( [id://996163]=note: print w/replies, xml ) Need Help??


in reply to Parsing SOAP::Lite results

What am I doing wrong?

Basically, $getToysResults->{Toys}{Toy} is an arrayref and not a hash

#!/usr/bin/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' ) }; warn $getToysResults; warn $getToysResults->{Toys}; warn $getToysResults->{Toys}{Toy}; warn $getToysResults->{Toys}{Toy}{ToyLocations}; __END__ HASH(0x9b4fdc) at - line 27. ArrayOfToy=HASH(0x9b506c) at - line 28. ARRAY(0x9b50bc) at - line 29. Not a HASH reference at - line 30.

See diagnostics, References quick reference, ref, Data::Diver, SOAP::SOM#valueof(node)

use Data::Diver qw/ Dive /; my $toyArrRef = Dive $getToysResults, qw/ Toys Toy /; for my $toy ( @{ $toyArrRef } ){ my $arrToyLoc = Dive $toy, qw/ ToyLocations ToyLocation /; for my $hash ( @{ $arrToyLoc } ){ print "$$hash{locationName}\n"; } } __END__ toybox shelf

Replies are listed 'Best First'.
Re^2: Parsing SOAP::Lite results
by Roboz (Novice) on Sep 28, 2012 at 10:57 UTC

    The Data::Diver module looks interesting. Alas, I'm coding on an offline system so I'll have wait a bit before trying that. Thank you for the insight though.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-03-28 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found