Subject: | [PATCH] a "tardiff" program |
Hi Kane,
Here's a really useful short program that I always wanted to write and finally got around to. It lets me download a tarball, expand it and make changes, then diff the changes against the original tarball. It was really easy using Archive::Tar, so I thought I'd share it - I thought it might make a nice addition to the Archive::Tar distribution.
---------------------------
#!/usr/bin/perl
use strict;
use Archive::Tar;
use Text::Diff;
my $tar = shift or die "Usage: $0 <tarfile>\n";
my $compressed = $tar =~ /\.t?gz$/;
$tar = Archive::Tar->new($tar, $compressed)
or die "Couldn't read tar file: $!";
my @files = $tar->get_files;
foreach my $file (@files) {
next unless $file->is_file;
my $name = $file->name;
diff( \($file->get_content), $name, {FILENAME_A => $name,
MTIME_A => $file->mtime,
OUTPUT => \*STDOUT} );
}