new tickets from slaven
[andk-cpan-tools.git] / bin / eliminate-outdated-annotations.pl
blob551410ddc9265fb5080fc1eb038c79244cadddc8
1 #!/usr/bin/perl
3 # use 5.010;
4 use strict;
5 use warnings;
7 =head1 NAME
11 =head1 SYNOPSIS
15 =head1 OPTIONS
17 =over 8
19 =cut
21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
23 =item B<--help|h!>
25 This help
27 =back
29 =head1 DESCRIPTION
31 Read from stdin a list of distros to eliminate. Rewrite annotate.txt
32 without them.
34 Clobbers annotate.txt without asking.
36 Was in use the first time 2013-11-02 and eliminated 784 annotation.
37 History on k83 says:
39 2014-02-20 03:38 ssh andreas@analysis cat filter-outdated-from-analysis-logfile.out | perl bin/eliminate-outdated-annotations.pl
41 The file filter-outdated-from-analysis-logfile.out was generated on analysis:
43 2014-02-20 02:36 ~/src/installed-perls/v5.16.0/4e6d/bin/perl bin/filter-outdated-from-analysis-logfile.pl bin/cnntp-solver.sh.out | tee ~/filter-outdated-from-analysis-logfile.out
45 =cut
48 use FindBin;
49 use lib "$FindBin::Bin/../lib";
50 BEGIN {
51 push @INC, qw( );
54 use Dumpvalue;
55 use File::Basename qw(dirname);
56 use File::Path qw(mkpath);
57 use File::Spec;
58 use File::Temp;
59 use Getopt::Long;
60 use Pod::Usage;
61 use Hash::Util qw(lock_keys);
63 our %Opt;
64 lock_keys %Opt, map { /([^=|!]+)/ } @opt;
65 GetOptions(\%Opt,
66 @opt,
67 ) or pod2usage(1);
68 if ($Opt{help}) {
69 pod2usage(0);
72 our %M;
73 while (<>) {
74 my($distro, $desc) = split " ", $_, 2;
75 my $type = "eq";
76 if ($distro =~ s/\.\.\.$//) {
77 $type = "substr";
79 $M{$type}{$distro} = $desc;
82 my @lines = do { open my $fh, "annotate.txt" or die; local $/ = "\n"; <$fh> };
83 open my $fh, ">", "annotate.txt" or die;
84 my $skipped = 0;
85 ANNO: for my $line (@lines) {
86 my($distro) = $line =~ /(\S+)/;
87 if (exists $M{eq}{$distro}) {
88 $skipped++;
89 next ANNO;
90 } else {
91 for my $substr (keys %{$M{substr}}) {
92 if (substr($distro,0,length($substr)) eq $substr) {
93 $skipped++;
94 next ANNO;
98 print $fh $line;
100 warn "rewrote annotate.txt and skipped[$skipped]\n";
102 # Local Variables:
103 # mode: cperl
104 # cperl-indent-level: 4
105 # End: