#6 Website Link Checker

One of the most vexing problems facing a webmaster is making sure that all the links on their website are correct. Internal links are difficult to deal with. Every time a file is added, removed, or changed on your website, there is the possibility of generating dead links.

External links are even worse. Not only are they not under your control, but they disappear without a moment's notice.

What's needed is a way of automatically checking a site for links that just don't work. That's where Perl comes in.

The Code

 1 # 2 # Usage: site-walk.pl <top-url> 3 # 4 use strict; 5 use warnings; 6 7 use HTML::SimpleLinkExtor; 8 use LWP::Simple; 9 use URI::URL; 10 11 my $top_url; # The URL at the top of the tree 12 13 ...

Get Wicked Cool Perl Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.