#!/usr/bin/perl
use strict;
use warnings;
use Archive::Zip::SimpleZip qw($SimpleZipError) ;
use File::Basename;
use Text::Glob;
sub walk
{
my $zip = shift;
my $path = shift ;
my $depth = shift // 1 ;
my $indent = ' ' x $depth;
for my $p (<$path/*>)
{
my $filename = basename $p;
my $dir = dirname $p;
if (-d $p)
{
print $indent . "$filename [as $filename.zip]\n";
my $newfh = $zip->openMember(Name => $filename . ".zip");
my $newzip = new Archive::Zip::SimpleZip $newfh, Stream => 1
or die "Cannot create zip file '$filename.zip': $SimpleZipError\n" ;
walk($newzip, $p, $depth + 1);
$newzip->close();
}
else
{
print $indent . "$filename\n";
$zip->add($p, Name => $filename);
}
}
}
my $zipfile = $ARGV[0];
my $path = $ARGV[1] ;
my $zip = new Archive::Zip::SimpleZip $zipfile
or die "Cannot create zip file '$zipfile': $SimpleZipError\n" ;
print "$path\n";
walk($zip, $path);
创建一个嵌套的压缩文件来播放
$ echo hello >hello.txt
$ zip 1.zip hello.txt
$ zip 2.zip 1.zip
$ zip 3.zip 2.zip
1条答案
按热度按时间but5z9lq1#
下面是一个Perl脚本
nested-unzip
,它遍历嵌套的zip文件并打印最里面的zip文件的内容。创建一个嵌套的压缩文件来播放
最后运行脚本