例如,文件夹包含10个XML文件。将文件夹转换为具有该文件夹名称的单个Zip文件
use strict;
use warnings;
use IO::Compress::Zip qw(zip $ZipError) ;
my $file = $ENV{"HOME"}."C:/zip";
my $s = zip [ $file, $file2 ] => $ENV{"HOME"}."C:/zip/new_.zip" , zip64 => 1
or die "zip failed: $ZipError \n";
更新:建议代码:
use strict;
use warnings;
use IO::Compress::Zip qw(zip $ZipError) ;
my $files="C:/zip";
my @file = "<$files/*.xml>";
zip \@file => 'output.zip'
or die "zip failed: $ZipError\n";
更新:建议代码:
use strict;
use warnings;
use IO::Compress::Zip qw(zip $ZipError) ;
my $dir="C:/zip";
my @files = <$dir/*.xml>;
print @files;
zip \@files => 'output.zip'
or die "zip failed: $ZipError\n";
答案 0 :(得分:1)
documentation for the module that you are using似乎有一些与你想要做的非常接近的例子。
my @files = <*.txt>;
zip \@files => 'output.zip'
or die "zip failed: $ZipError\n";
或者
zip [ <*.txt> ] => 'output.zip'
or die "zip failed: $ZipError\n";
您只需要编辑它以在几个地方包含目录名称。