in reply to Problem with HEAD.. but I think can be related with DNS

Works for me. Note you are not doing a HEAD request, but a GET. I changed your sub a little (moved the use statements to the top of the script).

sub simple_get { my $url = shift; my $ua = LWP::UserAgent->new; my $request = HTTP::Request->new(GET => $url); my $response = $ua->request($request); warn "ERROR!" unless $response->is_success; print $response->as_string; }

And this is the output–

200 OK Server: Welcome to UniProt FTP service. Content-Length: 151 Content-Type: text/plain Last-Modified: Wed, 19 Mar 2014 14:00:00 GMT Client-Date: Thu, 20 Mar 2014 17:25:38 GMT Client-Request-Num: 1 UniProt Knowledgebase Release 2014_03 consists of: UniProtKB/Swiss-Prot Release 2014_03 of 19-Mar-2014 UniProtKB/TrEMBL Release 2014_03 of 19-Mar-2014

Replies are listed 'Best First'.
Re^2: Problem with HEAD.. but I think can be related with DNS
by angeloulivieri (Novice) on Mar 20, 2014 at 17:31 UTC
    Aargh!! This is mine with you code:
    ERROR! at test_link.pl line 85. 404 File 'reldate.txt' not found Client-Date: Thu, 20 Mar 2014 16:50:25 GMT
    Something is not working for me but I cannot find out what... I have two parts of my code: - in the first I simply check for the link if it is correct - in the second I download the file corresponding to this link In the second I adjusted the code by doing a double attempt: one using LWP (HTTP::Request->new (GET => $link)) and another using File::Fetch. With File::Fetch function the download is working but not with HTTP::Request
      Does anyone has an idea of why this is happening?
        I was wondering if there is another way to check if an URL is working. Is HEAD the only one?
        I was asking also if there is a different way from HEAD to check if a URL is working. Because actually I want to check the link and, after a while, download it. For the download I find out the FILE::FETCH module that helped me. For the URL check I can't find anything...