ricksj
Technical User
- Sep 2, 2009
- 3
I'm trying to extract files of certain extention from a zip. The following code doesn't work. Any ideas out there, or other suggestions?
Code:
#!/usr/bin/perl
use File::Basename;
use File::Path;
use Archive::Zip;
use Archive::Extract;
my ($inputFile, $zipname, $unzipDir, $zipDir);
if ($ARGV[0]) {
$inputFile = $ARGV[0];
}
my ($zipname, $zipDir) = fileparse($inputFile);
my $unzipDir = $zipDir.'pod';
unless(-d $unzipDir) {
mkpath($unzipDir);
}
print "\nInput file: ". $inputFile ."\n";
print "Zip file: ". $zipname ."\n";
print "Unzip Dir: ". $unzipDir ."\n";
if (-f $inputFile) {
chdir($zipDir) or die "Can\'t chdir to $zipDir";
my $zip = Archive::Zip->new($zipname);
print "extracting files from $zipname to $unzipDir ...\n";
$zip->extractTree('*.cli', $unzipDir);
print "done.\n\n";
} else {
print "\n ### ATTENTION: ###\n The file $inputFile does not exist.\n $InputFileText\n ";
}