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

I have downloaded LWP module from CPAN and installed it successfully. When i tried using the module in one of my programs, i was not able to connect to the mentioned url. whereas the same program worked properly in a different machine and i was able to fetch the results. The program which gave an error was .....
"Couldn't get http://www.syfpeithi.de/scripts/MHCServer.dll/EpitopePre +diction?Motif=ALL&amers=9&SEQU=ALFKTPLSV &DoIT=++Run++ at test.pl line 16, <IN> line 1."
The program is given below. Is it something to do with the HTTP server in my machine????
#!/usr/bin/perl use lib "/home/guest/modules/libwww-perl-5.812/lib"; use LWP::Simple; open(IN,"all_peptides") or die "Cant open file\n"; while (eof(IN)==0) { $i++; chomp($line=<IN>); open(OUT,">/home/guest/$line.html") or die "Cant open $line.txt file \ +n"; my $url="http://www.syfpeithi.de/scripts/MHCServer.dll/EpitopePredicti +on?Motif=ALL&amers=9&SEQU=$line&DoIT=++Run++"; my $content = get $url or die "Couldn't get $url" unless defined $cont +ent; print OUT "$content"; close OUT; } close IN;

Replies are listed 'Best First'.
Re: HTTP problem while using LWP module
by mscharrer (Hermit) on Apr 29, 2008 at 19:08 UTC
    The error message indicates that $line still has a line break at its end (&DoIT starts on a new line). It seems that your chomp is not working probably because the input file has different line endings as the computer you run the script on. Was the input file created under Windows and the script running under Linux now? Was the different machine from a different type, i.e. a Windows machine?

    First of all add at the very beginning:

    use strict; use warnings; #use diagnostics; # if you get warnings
    and then, to be save:
    $line =~ s/\015?\012?\Z//m;
    after
    chomp($line=<IN>);
    Tell us if the problem disappears.
Re: HTTP problem while using LWP module
by almut (Canon) on Apr 29, 2008 at 20:11 UTC

    Probably not directly related to your problem... but note that the $content variable at the end of the line

    my $content = get $url or die "Couldn't get $url" unless defined $cont +ent;

    is not the variable you presumably think it is (i.e. the my $content from the beginning of the line). Rather, it's a global variable... (use strict; would have warned you! 'Global symbol "$content" requires explicit package name...').

    Thus it'll remain undefined, even on subsequent iterations of the while loop, after my $content has been sucessfully assigned some content.

    I'm not really sure what your intention is behind that unless defined $content, but expect it to not be working one way or another... (at best, it's useless :)

      We rectified that the problem is with the proxy settings..
Re: HTTP problem while using LWP module
by shmem (Chancellor) on Apr 29, 2008 at 19:12 UTC
    Is it something to do with the HTTP server in my machine?

    No, since you are contacting a remote HTTP server. It could have to do with proxy settings (server you have to contact which fetches the page on your behalf, because you are not allowed to do so directly due to network connectivity restrictions), or it is a resolver issue (from that machine it;s not possible to translate the server name to an IP address).

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}