Thanks for the info. 

However, when I print 
print "content $request->content \n"; I get "content
HTTP::Request=HASH(0x8546b3c)->content"
and print "$response->message \n"; give me "message
HTTP::Response=HASH(0x8546b60)->message"

Am I doing something wrong here ?

Thanks
Praful


-----Original Message-----
From: Oliver Schnarchendorf [mailto:[EMAIL PROTECTED]
Sent: Friday, April 02, 2004 11:03 AM
To: Bajaria, Praful
Cc: '[EMAIL PROTECTED]'
Subject: Re: New to Perl


On Fri, 2 Apr 2004 10:53:46 -0800 , Bajaria, Praful wrote:
> my $ua = LWP::UserAgent->new;
> $url = "http://www.cnn.com";;
> $response = $ua->get($url);
> if ($response->is_success) {
>       print "web site is working\n";
> } else { 
>       print "web site is not working\n";
> }
> quesion:
> 1) if the site is not woring, I would like to know why ?. How can I
retrieve
> the error code?
> 2) what is the fail value ? i.e. $response->not_working.. etc.
Hello Bajaria,

        if the web site request ($ua->get()) fails $response->is_success
will be false. By false I mean it isn't set to 1 which equals true. In your
above example you would end up in the 'else'-block.

        To find out which error occured you need to take a look at
$response->code. The number found in $response->code is in the range from
100 to 599. You can find more about these return codes by visiting
<http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>.

        To get a short human readable message about the meaning of
$response->code take a look at $response->message.

        You can find out much more by entering the following line at the
command prompt (or the terminal):

        perldoc LWP::UserAgent
        perldoc HTTP::Response

thanks
/oliver/

Reply via email to