Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using wildcards with Archive::Extract

Status
Not open for further replies.

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 ";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top