【发布时间】:2014-10-28 06:04:06
【问题描述】:
我在父目录中有多个子文件夹,每个子文件夹有 10 多个 zip 文件。例如。 父目录:/parentdir 子目录:/parentdir/2011-01,2011-02... 直到 2014-06,依此类推.. 每个月。
每个子目录:file1.zip, file2.zip, ... file10.zip
我想使用 perl 脚本解压缩同一子文件夹中的所有文件,并在解压后删除 .zip 文件或将 file1.zip 解压缩到 file1
您能帮忙在 unix 机器上使用 PERL 脚本来实现吗?
有可能使用
use strict;
use warnings;
use IO::Uncompress::Unzip qw(unzip $UnzipError);
my $zipfile = $ARGV[0];
my $u = new IO::Uncompress::Unzip $zipfile
or die "Cannot open $zipfile: $UnzipError";
die "Zipfile has no members"
if ! defined $u->getHeaderInfo;
}
但它提供了仅解压缩/解压缩一个文件的选项
米勒的回答更新
使用http://pkgs.org/centos-6/epel-i386/perl-Path-Class-0.25-1.el6.noarch.rpm.html 并安装了 rpm for Path::Class for per to recon.,现在仍然无法解压缩子文件夹中的文件:IO::Uncompress::Unzip: input parameter not a filename, filehandle , unzipper.pl 第 13 行的数组引用或标量引用
我有一个父文件夹 api_parent_folder 在子文件夹中 - 2014-01、2014-02 ...
在上述脚本中,我已将 /parentdir 更改为 /mnt/api_parent_folder
我一直在下面..
现在仍然无法解压缩子文件夹中的文件:IO::Uncompress::Unzip: unzipper.pl 第 13 行的输入参数不是文件名、文件句柄、数组引用或标量引用
【问题讨论】:
标签: perl