new perls v5.39.10
[andk-cpan-tools.git] / bin / cleanup-error-downloads.pl
blob0bb6fe8c2269c09bdff1c5e870780d6ecbf4aa21
1 #!/usr/bin/perl
3 use Sys::Hostname;
4 die "not yet ported to ds8143" if hostname eq "ds8143";
6 # use 5.010;
7 use strict;
8 use warnings;
10 =head1 NAME
14 =head1 SYNOPSIS
18 =head1 OPTIONS
20 =over 8
22 =cut
24 my @opt = <<'=back' =~ /B<--(\S+)>/g;
26 =item B<--help|h!>
28 This help
30 =back
32 =head1 DESCRIPTION
34 Quick and dirty: we have plenty of files containing
36 <h1 class="pagetitle">Error</h1>
38 and/or
40 <title>CPAN Testers Reports: Error</title>
42 and/or
44 <h2>Error</h2>
46 They all simply get removed together with their headers files.
48 =cut
51 use FindBin;
52 use lib "$FindBin::Bin/../lib";
53 BEGIN {
54 push @INC, qw( );
57 use Dumpvalue;
58 use File::Basename qw(dirname);
59 use File::Path qw(mkpath);
60 use File::Spec;
61 use File::Temp;
62 use Getopt::Long;
63 use Hash::Util qw(lock_keys);
65 our %Opt;
66 lock_keys %Opt, map { /([^=]+)/ } @opt;
67 GetOptions(\%Opt,
68 @opt,
69 ) or pod2usage(1);
71 use File::Find;
72 $|=1;
73 my $i = 0;
74 find(
75 sub {
76 return unless /^\d+\.gz$/;
77 return if -s $File::Find::name > 3000;
78 open my $fh, "-|", zcat => $File::Find::name or die "Could not open '$File::Find::name': $!";
79 my $delete;
80 while (<$fh>) {
81 if (m{<h1 class="pagetitle">Error</h1>}) {
82 $delete++;
83 last;
86 if ($delete) {
87 unlink $File::Find::name or die "Could not unlink '$File::Find::name': $!";
88 my $headers = $File::Find::name;
89 $headers =~ s/gz$/headers/;
90 unlink $headers or die "Could not unlink '$headers': $!";
91 $i++;
92 print "\r$i ";
95 "/home/ftp/cpantesters/reports"
97 print "\n";
99 # Local Variables:
100 # mode: cperl
101 # cperl-indent-level: 4
102 # End: