----- Original Message -----
From: "Kprasad" <[email protected]>
#!/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 respectively contains 3 files and two files and after
extraction 'c:/onfly/first' should contain 3 files 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!');}
}
#################################################
#################################################
Maybe you just need to create a different Archive::Zip object for each zip
file. Something like (untested):
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); # imports
#mkdir "c:/onfly";
my $localdir="c:/onfly";
opendir(DIR, $localdir) || print "\nerror\n";
my @zipfiles=grep /$ARGV[0].*\.zip/, readdir(DIR);
close(DIR);
foreach $zipfiles (@zipfiles)
{
my $obj = Archive::Zip->new(); # new instance
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!');}
}
__END__
I saw this near the end of the Archive::Zip documentation:
## quote ##
When not to use Archive::Zip
If you are just going to be extracting zips (and/or other archives) you
are recommended to look at using Archive::Extract instead, as it is much
easier to use and factors out archive-specific functionality.
## end quote ##
Cheers,
Rob
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs