5 check_URLs.pl - validate URLs located in module code and POD
9 B<check_URLs.pl> [B<-d|--dir> path] [B<-v|--verbose>] [B<-?|-h|--help>]
13 Checks code and POD of all bioperl-live modules for URLs, and validates them.
15 Output is a series of lines containing two fields, tab separated.
16 The first field is the file with the bad URL, the second is the URL itself.
18 The whole URL is not retrieved, only a HTTP "HEAD" request is done
19 to see if the URL exists on the server. The request is done using
20 B<LWP::Simple> so the B<http_proxy> environmental variable will be
23 The URL parsing may not be perfect - although I use the B<Regexp::Common::URI>
24 module, I have to manually clean up some URLs which are embedded in Perl
25 strings to convert the matched URL to a more probable real world URL,
26 e.g. most URLs don\'t end in "'," or ")" :-)
34 use Regexp
::Common
qw(URI);
38 # command line options
41 my ($verbose, $dir, $help) = (0, '../Bio/', undef);
43 'v|verbose' => \
$verbose,
45 'h|help|?' => sub{ exec('perldoc',$0); exit(0) }
58 find
( \
&find_modules
, $dir );
61 # validate unique URLs and print fail cases to stdout
64 for my $url (keys %URL) {
65 print STDERR
"Checking $url ... ";
67 print STDERR
($ok ?
'ok' : 'FAIL!'), "\n";
69 for my $file (@
{ $URL{$url} }) {
70 print "$file\t$url\n";
75 print STDERR Dumper
(\
%URL) if $verbose;
78 # this is where the action is
82 # only want files with .pm
83 return unless m/\.pm$/;
87 print STDERR
"$fname\n" if $verbose;
90 my $text = do { local( @ARGV, $/ ) = $fname ; <> } ;
93 while ($text =~ m/$RE{URI}{HTTP}{-keep}/g) {
95 # remove Perl code if URL was embedded in string and other stuff
96 $url =~ s/\s*[.,;'")]*\s*$//;
97 print STDERR
"$url\n" if $verbose;
98 push @
{ $URL{$url} } , $File::Find
::name
;
107 =item B<-d | --dir> path
109 Overides the default directory to recursively look for .pm file
110 (Default is '../Bio')
112 =item B<-v | --verbose>
114 Show the progress through files during the POD checking.
116 =item B<-? | -h | --help>
126 User feedback is an integral part of the evolution of this and other
127 Bioperl modules. Send your comments and suggestions preferably to
128 the Bioperl mailing list. Your participation is much appreciated.
130 bioperl-l@bioperl.org - General discussion
131 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
133 =head2 Reporting Bugs
135 Report bugs to the Bioperl bug tracking system to help us keep track
136 of the bugs and their resolution. Bug reports can be submitted via the
139 http://bugzilla.open-bio.org/
141 =head1 AUTHOR - Torsten Seemann
143 Email: torsten-dot-seemann-at-infotech-dot-monash-dot-edu-dot-au