SOAP::Lite, Data::Dumper and getting the values

T

Tomasz Chmielewski

My hosting provider lets me change the IP assigned to each of the servers (IP failover).
It can be done in the web interface, but in reality, it's much better to do this automatically with Heartbeat as it detects that one of the servers is down.


For that, there is some Perl code using SOAP::Lite - but I'm not sure how I can get the values out of it to use them in my own code.


my $result = $soap->call( 'dedicatedFailoverList' => ($session, $hosts{$hostname}) );
my $return = $result->result();


Now, Data::Dumper would return this - I'd like to access the values through a hash, array, variable, but I' not sure how:

print $return;

MyArrayOfDedicatedFailoverStructType=ARRAY(0x25608d8)


print Dumper $return;

$VAR1 = bless( [
bless( {
'routedTo' => 'aaa.bbb.ccc.ddd',
'comment' => 'webserver failover',
'ip' => '1.1.1.1',
'ssl' => 0
}, 'dedicatedFailoverStruct' ),
bless( {
'routedTo' => 'aaa.bbb.ccc.ddd',
'comment' => 'webserver failover',
'ip' => '2.2.2.2',
'ssl' => 0
}, 'dedicatedFailoverStruct' ),
bless( {
'routedTo' => 'aaa.bbb.ccc.ddd',
'comment' => 'webserver failover',
'ip' => '3.3.3.3',
'ssl' => 0
}, 'dedicatedFailoverStruct' ),
bless( {
'routedTo' => 'aaa.bbb.ccc.ddd',
'comment' => 'webserver failover',
'ip' => '4.4.4.4',
'ssl' => 0
}, 'dedicatedFailoverStruct' ),
bless( {
'routedTo' => undef,
'comment' => undef,
'ip' => undef,
'ssl' => 0
}, 'dedicatedFailoverStruct' )
], 'MyArrayOfDedicatedFailoverStructType' );
 
M

Marc Girod

I'd like to access the values through a hash, array, variable, but I' notsure how:

for (@$return) { print $_->{ip} if defined $_->{ip} }

$return is an array of references to dedicatedFailoverStruct.
Did I understand your question?

Marc
 
R

RedGrittyBrick

My hosting provider lets me change the IP assigned to each of the servers (IP failover).
For that, there is some Perl code using SOAP::Lite - but I'm not sure how I can get the values out of it to use them in my own code.

my $result = $soap->call( 'dedicatedFailoverList' => ($session, $hosts{$hostname}) );
my $return = $result->result();
print Dumper $return;

$VAR1 = bless( [
bless( {
'routedTo' => 'aaa.bbb.ccc.ddd',
'comment' => 'webserver failover',
'ip' => '1.1.1.1',
'ssl' => 0
}, 'dedicatedFailoverStruct' ), ...
], 'MyArrayOfDedicatedFailoverStructType' );


Presumably, somewhere there is a dedicatedFailoverStruct.pm that you
should have in a `use dedicatedFailoverStructType'. Then you can use
that object's methods. Presumably there is a
MyArrayofDedicatedFailoverStruct.pm object with iterator methods that
return it's elements. Which would make it possible to use the $return
value in an OO style.

I don't like the class names though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top