ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-users
perl-win32-users
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved