Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Getting deep data from SOAP::Lite Result

by kcott (Chancellor)
on Oct 17, 2012 at 09:02 UTC ( #999495=note: print w/replies, xml ) Need Help??

in reply to Getting deep data from SOAP::Lite Result

G'day Roboz,

Firstly, the data structure you present is invalid. In the code below, I've added a closing brace to 'Mineral' => { .... Also, you show $Var1 as being a reference to a hashref: I don't know if that's correct or another typo - the following code assumes it is correct.

This code shows how you might go about achieving what you're after. I'll leave you to make adjustments for whatever typos may exist.

#!/usr/bin/env perl use strict; use warnings; my $SOAPresult = \{ 'Thing' => [ { 'Animal' => { 'ThingName' => 'Dog', 'ThingID' => '123' } }, { 'Veg' => { 'ThingName' => 'Carrot', 'ThingID' => '42' } }, { 'Mineral' => { 'ThingName' => 'Talc', 'ThingID' => '007' } } ] }; my $SOAPresult_deref = $$SOAPresult; my @types = qw{Animal Veg Mineral}; for my $type (@types) { foreach my $e ( @{ $SOAPresult_deref->{Thing} } ) { next unless exists $e->{$type}; print "Wildcard = $type\n"; print "$e->{$type}{ThingName}\n"; } }


$ Wildcard = Animal Dog Wildcard = Veg Carrot Wildcard = Mineral Talc

-- Ken

Replies are listed 'Best First'.
Re^2: Getting deep data from SOAP::Lite Result
by Roboz (Novice) on Oct 17, 2012 at 09:20 UTC

    Thanks for catching that closing bracket. I'm working on an offline system so I have to manually transcribe vs. cut-n-paste... Your assumption is correct, $Var1 is a reference. I was trying to just read the ThingName without knowing (or caring) what type it was. I used animal, veg and mineral as a stand in for a long list of specifics that I don't have access to, alas. I would rather use an XPath statement with valueof but I always get the "Can't call method "valueof" without a package or object reference..." error.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999495]
[atcroft]: stevieb: I have berrybrew installed on a Win machine, and I noticed that with perlbrew you can "upgrade" a particular installed version... any chance of doing something similar in the
[atcroft]: future with berrybrew?
[atcroft]: stevieb: Also, one other odd question... is it possible to set it up so that all the versions installed can use a single directory that they pull module sources into, rather than duplicating files? (Am I making sense, or do I have too high a CBC
[atcroft]: (caffeine-blood content) atm?)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2017-04-29 05:11 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.