Archive::Zip problem
by Kprasad other posts by this author
Jul 1 2009 9:39PM messages near this date
view in the new Beta List Site
Re: 2 MinGW-related feature requests.
|
Re: Archive::Zip problem
Hi All
I've simple perl program which should be used to extract two .zip files at the same time. Di
rectory for unzipping will be the name of individual zip file.
Problem: First zip's content extract perfectly but after unzipping Second zip it contains th
e files of first zip too.
I've two zip files i.e., first.zip and second.zip which respectively contains 3 files and tw
o files and after extraction 'c:/onfly/first' should contain 3 files and c:/onfly/second' sh
ould contain 2 files only.
CODE:
#!/usr/bin/perl
use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); # imports
#mkdir "c:/onfly";
my $localdir="c:/onfly"; ## I've two zip files i.e., first.zip and second.zip which respecti
vely contains 3 files and two files and after extraction 'c:/onfly/first' should contain 3 f
iles and c:/onfly/second' should contain 2 files only
$obj = Archive::Zip-> new(); # new instance
opendir(DIR, $localdir) || print "\nerror\n";
my @zipfiles=grep /$ARGV[0].*\.zip/, readdir(DIR);
close(DIR);
foreach $zipfiles (@zipfiles)
{
if($obj-> read("$localdir/$zipfiles") == AZ_OK) # read file contents
{
print "$zipfiles\n";
$unzip=substr($zipfiles,0,length($zipfiles)-4);
print "$unzip\n";
if($obj-> extractTree(undef, "$localdir/$unzip/")){print "Extracting $zipfiles";}}
else{die('Error in file!');}
}
Kanhaiya Prasad
Thread:
Kprasad
Sisyphus
Chris Wagner
|