Re: Link verification?
Benjamin M. Hill (Benjamin.M.Hill@dartmouth.edu)
26 Aug 98 10:57:51 EDT
--- Walter Ian Kaye wrote:
> What's the easiest way to check that a web address exists,
> and what do I need installed in order to do that?
--- end of quote ---
--- Neil Bowers wrote:
What you need is LWP, and the specific modules are:
use HTTP::Request;
use HTTP::Response;
use LWP::UserAgent;
$agent =3D LWP::UserAgent->new();
$request =3D HTTP::Request->new('HEAD', $URL);
$response =3D $agent->request($request);
You can then check $response->code to determine whether the URL is =
there.
You can use HTTP::Status to get symbolic names for the different =
codes.
--- end of quote ---
If you wanted to keep it simple, is there technically anything =
wrong with this, or is it just bad coding style?
use LWP::Simple; # get, head
@head =3D head($current_url);
return unless @head;