13 compare-snapshots.pl file file
21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
31 Reads two snapshot files and outputs differing modules.
33 FTR, snapshot files are generated within the CPAN shell by running C<autobundle>.
43 use lib
"$FindBin::Bin/../lib";
49 use File
::Basename
qw(dirname);
50 use File
::Path
qw(mkpath);
54 use Hash
::Util
qw(lock_keys);
55 use List
::MoreUtils
qw(uniq);
58 lock_keys
%Opt, map { /([^=]+)/ } @opt;
63 my($lfile,$rfile) = @ARGV;
64 pod2usage
(1) unless $rfile;
67 for my $tuple ([$left,$lfile],
70 my($snap,$file) = @
$tuple;
71 open my $fh, $file or die "Could not open '$file': $!";
73 SNAPLINE
: while (<$fh>) {
74 if (/^=head1\sCONTENTS$/) {
77 } elsif (/^=head1\s/) {
80 next SNAPLINE
unless $in_list;
81 next SNAPLINE
if /^\s*$/;
82 my($mod,$v) = split " ", $_;
86 my(@miss_left,@miss_right,@diff_version);
88 for my $m (uniq
keys %$left, keys %$right) {
89 $c1 = length $m if length $m > $c1;
90 if (! exists $right->{$m}) {
91 push @miss_right, [$m, $left->{$m}];
93 } elsif (! exists $left->{$m}) {
94 push @miss_left, [$m, $right->{$m}];
97 next if $left->{$m} eq $right->{$m};
98 push @diff_version, [$m, $left->{$m}, $right->{$m}];
101 for my $tuple (sort {$a->[0] cmp $b->[0]} @miss_right) {
102 printf "%${c1}s %${c2}s =>\n", @
$tuple;
104 for my $tuple (sort {$a->[0] cmp $b->[0]} @miss_left) {
105 while (length $tuple->[0] > $c1) {
106 (my $trim,$tuple->[0]) = unpack("a" . $c1 . "a*", $tuple->[0]);
109 printf "%${c1}s %${c2}s => %${c2}s\n", $tuple->[0], "", $tuple->[1];
111 for my $tuple (sort {$a->[0] cmp $b->[0]} @diff_version) {
112 printf "%${c1}s %${c2}s => %${c2}s\n", @
$tuple;
117 # cperl-indent-level: 4