in reply to Re: Multiple zip files from directories!
in thread Multiple zip files from directories!

It is making sense now, have one question if you could on this part of the code:
... if ($total + $member->compressedSize > $limit) { $zip->writeToFileNamed("zipped_$archiveCount.zip") == AZ_OK or + die $!; $archiveCount++; print "Total archive size: $total bytes\n\n"; $total = 0; my $zip = Archive::Zip->new; } $zip->addMember($member); # <---- This line ...
the last line here where the files are added to the zip file(s), I tried this: $zip->addMember($member) unless $zip->addMember($member); to avoid duplicated files inside of the zip files. But what is happening is that the zip files are been created, that is good, but the files inside of the zip are been added repeatedly. I just need to prevent this somehow. Any suggestions?

Replies are listed 'Best First'.
Re^3: Multiple zip files from directories!
by kennethk (Abbot) on Sep 15, 2011 at 20:44 UTC
    Like I said, untested. The line my $zip = Archive::Zip->new; should have read $zip = Archive::Zip->new;. Rather than creating a new archive in the variable $zip, I was creating a new archive and storing it in a new $zip variable that went out of scope immediately,; hence I kept adding to the old archive. The corrected, functional version is posted in an updated Re: Multiple zip files from directories!