Hi All
I've simple perl program which should be used to extract two .zip files at the 
same time. Directory for unzipping will be the name of individual zip file.
Problem: First zip's content extract perfectly but after unzipping Second zip 
it contains the files of first zip too.
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.

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 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!');}
    }

Kanhaiya Prasad
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to