Re: Unable to connect a website using LWP
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 23 Feb 2006 08:20:10 -0800
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
.
- Follow-Ups:
- Re: Unable to connect a website using LWP
- From: Sisyphus
- Re: Unable to connect a website using LWP
- From: harryfmudd [AT] comcast [DOT] net
- Re: Unable to connect a website using LWP
- References:
- Unable to connect a website using LWP
- From: prasanna_ssb
- Re: Unable to connect a website using LWP
- From: Paul Lalli
- Re: Unable to connect a website using LWP
- From: harryfmudd [AT] comcast [DOT] net
- Unable to connect a website using LWP
- Prev by Date: Re: Unable to connect a website using LWP
- Next by Date: Re: Unable to connect a website using LWP
- Previous by thread: Re: Unable to connect a website using LWP
- Next by thread: Re: Unable to connect a website using LWP
- Index(es):
Relevant Pages
|
|