Search code examples
perlsoapdata-dumper

Retrieving Data::Dumper elements


I'm using Data::Dumper to retrieve information from a server with SOAP messaging and need some assistance with assigning the return values for processing. My code is:

my $cm = new SOAP::Lite
encodingStyle => '',
uri => "$axltoolkit",
proxy => "https://$cucmip:$axl_port/axl/";

my $res =$cm->getUser(SOAP::Data->name('userid' => "387653"));

unless ($res->fault) {
    $Data::Dumper::Incident=3;
    my( $reply ) = $res->paramsall();
    my ($devices) = $reply->{user}{associatedDevices}{device};
    print $devices->[0]."\n";
    print $devices->[1]."\n";
    print $devices->[2]."\n";

{device} could contain any number of elements so instead of calling out $devices->[0],[1],etc - is it possible to spit out all of the returned devices? I've tried $_ and @_ but no luck since it just returns the first of the devices.

Any help is appreciated.

Thanks


Solution

  • You mean

    foreach my $device (@$devices) {
        print "$device\n";
    }
    

    ?

    Or more concisely

    print "$_\n" foreach @$devices;