Go Premium for a chance to win a PS4. Enter to Win


dead-link detection

Posted on 1998-11-30
Medium Priority
Last Modified: 2013-12-25
I need a perl script to detect a dead-link
something like this:
            deadLink( URL )
deadLink() returns true if link exists, false otherwise.

Question by:shlomoy
  • 2
  • 2

Accepted Solution

squimph earned 400 total points
ID: 1829827
You can use the modules in the libwww package (http://www.perl.com/CPAN-local/modules/by-module/LWP/) to test a URL:

For example, call the following from the command line with the URL you want to test as the parameter:

$URL = $ARGV[0];
use LWP::UserAgent;
$ag = new LWP::UserAgent;
$ag->agent("CustomLinkChecker/1.0" . $ag->agent);
$req = new HTTP::Request GET => $URL;
$results = $ag->request($req);
if ( $results->is_success ) {
    print "URL exists.\n"

} else {
    print "Bad URL\n";

Author Comment

ID: 1829828
from: http://www.perl.com/CPAN-local/modules/by-module/LWP/libwww-perl-5.41.readme
---begin quote---
If you want to install a private copy of libwww-perl in your home
directory, then you should try to produce the initial Makefile with
something like this command:

  perl Makefile.PL LIB=~/perl

The Makefile.PL program will start out by checking your perl
installation for a few packages that are recommended to be installed
together with libwww-perl.
----end quote----

where can I obtain this makefile?

Expert Comment

ID: 1829829
Well, installing libwww-perl is a separate question but here goes...

First consider talking to your system administrator to ask that they install libwww in the central perl directory so everyone on the system can use it (most web servers already have it installed... I assume you've already checked)

If the admin refuses to install it, the instructions you have above will do it... 'perl Makefile.PL LIB=~/perl' will create a file called 'Makefile' ... then type 'make' and 'make install' to install the package.

Author Comment

ID: 1829830

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question