【问题标题】:How to search through archived files with Perl如何使用 Perl 搜索归档文件
【发布时间】:2008-09-25 17:17:59
【问题描述】:

使用 Perl 读取压缩目录内容的首选方法是什么?

【问题讨论】:

  • 您是要查看目录列表还是文件内容?

标签: perl search file-io compression


【解决方案1】:

CPAN 上有几个模块用于处理各种存档格式(zip、tar 等),您可能需要的是Archive::Zip

【讨论】:

  • 当您发布到(搜索)CPAN 的链接时,请确保您指向与作者和版本无关的 URL,以便它始终指向模块的最新版本。在这种情况下,这将是:search.cpan.org/perldoc?Archive::Zip
【解决方案2】:

存档::Zip

require Archive::Zip;
my $zip = Archive::Zip->new($somefile);
for($zip->memberNames()) {
  print "$_\n";
}

【讨论】:

    【解决方案3】:

    如果您想要 .tar.gz 存档的内容

    open(DIR_LISTING, "gzip -dc concert25.tgz | tar -tf -|") || die;
    while (<DIR_LISTING>) {
       print;
    }
    close (DIR_LISTING);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      • 2020-02-24
      • 1970-01-01
      相关资源
      最近更新 更多