use Archive::Tar;
use IO::Uncompress::Gunzip;
use IO::String;
# Do whatever you want with each file and its data
sub handle {
my ($name,$data) = @_;
print "file $name length ", length($data), $/;
}
my $filename = 'a.tgz';
my $outer = Archive::Tar->new($filename);
for my $outerfile ($outer->get_files) {
my $outerdata = $outer->get_content($outerfile->name);
my $inner = Archive::Tar->new(
IO::Uncompress::Gunzip->new(
IO::String->new($outerdata)));
for my $file ($inner->get_files) {
next unless $file->name =~ /^.._log$/;
handle $file->name, $inner->get_content($file->name);
};
}
It works, but will likely be dog slow. Since your archive is only 40M maybe it doesn't matter. |