Re: Unable to connect a website using LWP



harryfmudd [AT] comcast [DOT] net wrote:
Paul Lalli wrote:
prasanna_ssb@xxxxxxxxxxxxxx wrote:

Does LWP handle FTP addresses? I have no idea. But it seems like it
shouldn't have any reason to.

Actually, LWP handles FTP as well as HTTP, as

GET ftp://ftp.rcsb.org/pub/pdb/data/structures/all/pdb/

will demonsrate.

Hmm. Good to know. Thanks for the info.

if ($response->is_success == 0 ) { die "Cant get $url:\n
$response->status_line"; }

I would like to recommend, in lieu of your two lines, something like

$response->is_success or
die "Can't get $url:\n", $response->status_line, "\n";

The explicit '== 0' probably does what you think it does though, so
maybe it's just a matter of style.

It does do what the OP wants, but perhaps not for the reasons the OP
might suspect... If you trace the is_success method definitions
through to the actual code (you wind up in the HTTP::Status module),
you will see that it comes out to be the logical and'ing of two
inequality operations (testing if the status code returned is >= 200
and < 300). This is where perl magic comes into place. Normally, when
you compare an empty string to a number using the == operator, you'll
get a warning message. The result of boolean checks like inequality,
however, are not "normal":

$ perl -MData::Dumper -wle'
$x = q{};
print Dumper(\$x);
print "True" if $x == 0
'
$VAR1 = \'';
Argument "" isn't numeric in numeric eq (==) at -e line 1.
True

$ perl -MData::Dumper -wle'
$x = (5<3);
print Dumper(\$x);
print "True" if $x == 0
'
$VAR1 = \'';
True

Even though Data::Dumper seems to think the result of 5<3 is an empty
string, Perl treats it as a generic false value - empty string when
used as a string, but 0 when used as a number.

Paul Lalli

.



Relevant Pages

  • Re: Where to place a constant?
    ... an empty string has no ... you'll limit code reusability somewhat. ... That again depends on the implementation you use, not only on settings. ... That's of course a very good reason to write your own ones, ...
    (comp.lang.cpp)
  • VBS gets empty string
    ... the VBS gets empty string from COM. ... Dim mystring ... MsgBox' in some reason, ...
    (microsoft.public.vc.atl)
  • Re: coredump in df_readascii
    ... OS: AS3 ... Reason: df_commentschars is null. ... Strange. ... You can set it to an empty string, ...
    (comp.graphics.apps.gnuplot)
  • Re: Where to place a constant?
    ... > Okay... ... > no reason what so ever to use it... ... Learning is always a good reason to re-write certain standard classes. ...
    (comp.lang.cpp)
  • Re: empty quotes != not(string(.)) ????
    ... d> Hmm, I had this: ... This will be true if there is a node in nodeset, ... $activeLink] expression, equals to empty string. ...
    (microsoft.public.dotnet.xml)