21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
37 For the record: whatever we pass to ctgetreports as --cachedir will
38 then be populated with two subdirectories, cpantesters-show/ and
41 So in the past we had one cpantesters-show/ and one nntp-testers/
42 directory and now need tens of thousands of such directories.
44 When this program was written, we did it wrongly because the above
47 So after the first iteration we have
49 top-cachedir/nntp-testers/a/autobox-2.55/
51 But what we wanted was
53 top-cachedir/a/autobox-2.55/nntp-testers
55 What's the transformation in the second step?
57 cd top-cachedir/nntp-testers
60 mv $f ../$f/nntp-testers
68 use lib
"$FindBin::Bin/../lib";
74 use File
::Basename
qw(dirname);
75 use File
::Path
qw(mkpath);
79 use Hash
::Util
qw(lock_keys);
82 lock_keys
%Opt, map { /([^=]+)/ } @opt;
87 my $olddir = $Opt{fromdir
} ||= "nntp-testers-20111125";
88 $Opt{todir
} ||= "nntp-testers";
89 opendir my $dh, $olddir or die;
91 for my $dirent (readdir $dh) {
92 next if $dirent =~ /^\.\.?$/;
94 if ($dirent =~ /\.gz$/) {
95 open $fh, "-|", "zcat", "$olddir/$dirent" or die;
97 open $fh, "<", "$olddir/$dirent" or die;
101 next unless /CPAN Testers Reports: Report for (\S+?)</;
107 my $todir = sprintf "$Opt{todir}/%s/%s", substr($distv,0,1), $distv;
109 rename "$olddir/$dirent", "$todir/$dirent";
112 print "($i)" unless $i % 1000;
117 # cperl-indent-level: 4