如何使用Perl搜索归档文件
时间:2020-03-06 14:44:05 来源:igfitidea点击:
使用Perl读取压缩目录内容的首选方法是什么?
解决方案
CPAN上有几个模块可用于处理各种存档格式(zip,tar等),我们可能需要使用的模块是Archive :: Zip。
如果我们想要.tar.gz档案的内容
open(DIR_LISTING, "gzip -dc concert25.tgz | tar -tf -|") || die; while (<DIR_LISTING>) { print; } close (DIR_LISTING);
存档::邮编
require Archive::Zip; my $zip = Archive::Zip->new($somefile); for($zip->memberNames()) { print "$_\n"; }