How to search through archived files with Perl
-
02-07-2019 - |
Question
What is your preferred method for reading through the contents of zipped directories with Perl ?
Solution
There are several modules on CPAN for working with various archive formats (zip, tar, etc.), the one you're probably after is Archive::Zip.
OTHER TIPS
Archive::Zip
require Archive::Zip;
my $zip = Archive::Zip->new($somefile);
for($zip->memberNames()) {
print "$_\n";
}
If you want the contents of a .tar.gz archive
open(DIR_LISTING, "gzip -dc concert25.tgz | tar -tf -|") || die;
while (<DIR_LISTING>) {
print;
}
close (DIR_LISTING);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow