my $tar_obj = Archive::Tar->new;
$tar_obj->read( "my.tar")
# or just: my $tar_obj = Archive::Tar->new( "my.tar" );
####
use Archive::Tar;
# here's the slow approach to mucking with files in a tar set:
my $tar = Archive::Tar->new( "some.tar" );
my @filenames = $tar->list_files;
for my $filename ( @filenames ) {
my $filedata = $tar->get_content( $filename );
# do other stuff...
}
##
##
use Archive::Tar;
my $tar = Archive::Tar->new( "some.tar" );
my @files = $tar->get_files; # returns list of Archive::Tar::File objects
for my $file ( @files ) {
my $data = $file->get_content; # same as above, but no searching involved
# do other stuff...
}
##
##
my %cksums;
for my $file ( grep { $_->has_content } @files ) # only do non-empty files
{
next if $file->uname eq 'root'; # let's leave these alone
if ( $file->name =~ /\.[ch]$/ ) {
# do things with source code files here...
}
elsif ( exists( $cksums{ $file->cksum } )) {
# file's content duplicates another file we've already seen...
}
else {
$cksum{$file->cksum} = undef; # keep track of cksums
}
}