#!/usr/bin/perl


push @INC,"/groupes/poch/moumou/ordali/alitest";
print "@INC";

use strict;
use warnings;
use SOAP::Lite;

print "Connecting to DAS registry\n";

my $sources =
  SOAP::Lite->service(
        'http://www.dasregistry.org/services/das'
      . ':das_directory?wsdl' )->listServices();

foreach my $source ( @{$sources} ) {

    while ( my ( $key, $value ) = each( %{$source} ) ) {

        if ( ref $value eq 'ARRAY' ) {
            if ( $key eq 'coordinateSystem' ) {

                foreach my $coords ( @{$value} ) {
                    print "coordinate system:\n";
                    while ( my ( $dcskey, $dcsvalue ) =
                        each( %{$coords} ) )
                    {
                        printf "\t%-16s => %s\n", $dcskey, $dcsvalue;
                    }
                }

            } else {
                printf "%-16s => %s\n", $key, join( ', ', @{$value} );
            }

        } else {
            $value =~ s/\s+/ /gs;
            printf "%-16s => %s\n", $key, $value;
        }
    }
}

