9 watch -t -n 20 'perl ~k/sources/CPAN/GIT/trunk/bin/recent.pl -n 25 --burn-in-protection'
17 my @opt = <<'=back' =~ /B<--(\S+)>/g;
23 =item B<--alternative=i>
27 Normally we suppress Foo-3.33 when we have already seen Foo-4.44. With
28 this option we show all versions.
30 =item B<--burn-in-protection!>
34 =item B<--localroot=s>
36 Defaults to C</home/ftp/pub/PAUSE/authors>. Path to authors directory.
46 Show most recent uploads according to the RECENT file and mark the
47 currently processing one (according to ~/.cpan/loop-over-recent.state
50 The burn-in-protection changes something from time to time. This also
51 cleans up STDERR remnants that otherwise might annoy the user of
59 use CPAN
::DistnameInfo
;
60 eval {require Time
::Duration
};
61 our $HAVE_TIME_DURATION = !$@
;
65 use File
::Basename
qw(dirname);
66 use File
::Path
qw(mkpath);
71 use Hash
::Util
qw(lock_keys);
74 lock_keys
%Opt, map { /([^=|!]+)/ } @opt;
84 if (-e
"/home/k/sources/rersyncrecent/lib/") {
86 lib
->import("/home/k/sources/rersyncrecent/lib/");
89 require File
::Rsync
::Mirror
::Recent
;
91 unless (CPAN
::Version
->vge($File::Rsync
::Mirror
::Recent
::VERSION
, '0.4.5')) {
92 warn "WARNING: loaded version '$File::Rsync::Mirror::Recent::VERSION' maybe not sufficient. Loaded from $INC{'File/Rsync/Mirror/Recent.pm'}\n";
95 my $statefile = "$ENV{HOME}/.cpan/loop-over-recent.state";
96 my $max_epoch_worked_on = 0;
98 my $rx = qr!\.(tar.gz|tar.bz2|zip|tgz|tbz)$!; # see also loop-over...
102 my $state = do { open my $fh, $statefile or die "Couldn't open '$statefile': $!";
108 $max_epoch_worked_on = $state if $state;
110 $Opt{localroot
} ||= "/home/ftp/pub/PAUSE/authors";
111 $Opt{localroot
} =~ s
|/*$|/|; # ensure trailing slash
112 my $rf = File
::Rsync
::Mirror
::Recent
->new
114 localroot
=> $Opt{localroot
},
115 local => "$Opt{localroot}RECENT.recent",
117 my $have_a_current = 0;
118 my $recent_events = $rf->news(max
=>10*$Opt{n
});
121 $recent_events = [ grep { $_->{path
} =~ $rx
122 && $_->{type
} eq "new";
124 unless ($Opt{allowdups
}) {
125 $recent_events = [ grep { my $d = CPAN
::DistnameInfo
->new($_->{path
});
126 no warnings
'uninitialized';
130 for my $re (@
$recent_events) {
131 if ($re->{epoch
} == $max_epoch_worked_on) {
132 $re->{is_current
} = 1;
139 ITEM
: for my $i (0..$#$recent_events) {
140 my $item = $recent_events->[$i];
142 my $epoch = $item->{epoch
};
143 unless ($intro_done++) {
144 if ($HAVE_TIME_DURATION) {
145 printf " %s since latest upload\n", Time
::Duration
::duration
(time - $epoch);
147 printf " %7d seconds since latest upload (no Time::Duration?)\n", time - $epoch;
150 if ($max_epoch_worked_on) {
151 if ($item->{is_current
}) {
153 } elsif (!$have_a_current
154 && $max_epoch_worked_on > $item->{epoch
}
156 && $max_epoch_worked_on < $recent_events->[$i-1]->{epoch
}) {
157 printf "%1s %s\n", "*", scalar localtime $max_epoch_worked_on;
161 if ($Opt{showsize
}) {
162 my $abs = $Opt{localroot
} . $item->{path
};
163 $size = -s
$abs ?
sprintf(" %7d ",-s
$abs) : "_________";
169 scalar localtime $epoch,
171 substr($item->{path
},8),
173 if (my $trim = $Opt{linetrim
}) {
174 if (length $line > $trim) {
175 substr($line,$trim-3) = "...\n";
178 if ($Opt{"burn-in-protection"}) {
180 while (rand 30 < 1) {
183 if (length($line) > 80) {
184 while (length($line) > 80){
187 substr($line,80-1,1) = rand(30)<1 ?
"_" : ">";
189 while (length($line) < 80){
190 $line .= rand(30)<1 ?
"_" : " ";
199 if ($Opt{n
} && $count>=$Opt{n
}) {
204 print sprintf " found nothing of interest in %s\n", $rf->rfile;
205 } elsif ($Opt{"burn-in-protection"} && $count < $Opt{n
}) {
206 while ($count < $Opt{n
}) {
208 while (length($line) < 80){
209 $line .= rand(30)<1 ?
"_" : " ";
219 # cperl-indent-level: 2