Gkandoi has asked for the wisdom of the Perl Monks concerning the following question:

Hey all I've been trying to get some data using the SOAP Lite client using the following code:
#!/usr/bin/perl -w use SOAP::Lite; my $data = "D:array1.csv"; open(INPUT, $data) or die "Cannot open $data"; my $line = <INPUT>; while($line = <INPUT>) { $resultString = SOAP::Lite -> uri('http://www.brenda-enzymes.org/soap2') -> proxy('http://www.brenda-enzymes.org/soap2/brenda_server.php') -> getSequence("ecNumber*$line#source*Swiss-Prot#textmining*0") -> result; print $resultString; } close(INPUT);
I've a list of numbers in the form X.X.X.X in my array.csv file. These are the different values for the ecNumber in getSequence command. Whenever I run it, it gives me an empty string. Where am I going wrong in this? I guess the problem lies in: 'ecNumber*$line' portion.

Replies are listed 'Best First'.
Re: Whats wrong with this code?
by Corion (Patriarch) on Sep 08, 2014 at 19:49 UTC

    $line most likely contains a newline at the end. Maybe the service you're connecting to does not like that?

    Have you tried with a hardcoded value for $line?

      You mean by using something like ecNumber*X.X.X.X, directly?
      $resultString = SOAP::Lite -> uri('http://www.brenda-enzymes.org/soap2') -> proxy('http://www.brenda-enzymes.org/soap2/brenda_server.php') -> getSequence("ecNumber*1.1.1.1#source*Swiss-Prot#textmining*0") -> result;
      This code works fine.

        The next step then would be to compare what you have in $line to a hardcoded value. Like I already said, you most likely have a newline (and/or other stuff) at the end of $line and want to remove that before sending it off to the server:

        while( defined( my $line=<FILE> )) { my $sequence= "ecNumber*$line#source*Swiss-Prot#textmining*0"; print "Retrieving [$sequence]\n"; $resultString = SOAP::Lite -> uri('http://www.brenda-enzymes.org/soap2') -> proxy('http://www.brenda-enzymes.org/soap2/brenda_server.php') -> getSequence($sequence) -> result; };
Re: Whats wrong with this code?
by toolic (Bishop) on Sep 08, 2014 at 19:56 UTC