my $response = $ua->request(HTTP::Request->new('HEAD', $url)); if ($response->code == 200) { # url is valid } else { # there's something odd with the URL }