in reply to Re: unable to extract same file twice using Archive::Zip
in thread unable to extract same file twice using Archive::Zip

Your script (slightly modified) works for me:

use strict; use Archive::Zip qw(:CONSTANTS :ERROR_CODES); use File::Temp; warn "Using Archive::Zip $Archive::Zip::VERSION"; my $tmp = $ENV{'TEMP'}.'/zip/extractMember'; my $zip = Archive::Zip->new(); if ($zip->read('tmp2.zip') != AZ_OK) { die 'Einlesen klappt nicht.'; } foreach my $member ($zip->members()) { print($member->fileName()."\n"); my $target = File::Temp::tempnam($tmp, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXX'); print "First"; $member->extractToFileNamed($target); print "\n"; print "Second"; $target = File::Temp::tempnam($tmp, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +X'); $member->extractToFileNamed($target); print "\n"; } __END__ Using Archive::Zip 1.23 at tmp.pl line 5. tmp2.txt First Second

Note that I'm using an older version of Archive::Zip here. I also don't get the warning about the CRC32 mismatch:

format error: CRC or size mismatch while skipping data descriptor at C:/Programme/Perl/lib/Archive/Zip/ZipFileMember.pm line 189

Are you sure that your archive is OK? I created my test archive using 7zip.

I'll be upgrading to Archive::Zip 1.30 and retest.

Update: Upgraded to Archive::Zip 1.30 and it still works for me:

Using Archive::Zip 1.30 at tmp.pl line 5. tmp2.txt First Second

My guess is that your zip file is broken.

Replies are listed 'Best First'.
Re^3: unable to extract same file twice using Archive::Zip
by Pickwick (Beadle) on Jul 07, 2010 at 13:46 UTC
    My guess is that your zip file is broken.

    Seems you are right. I extracted the zip contents using WinRar, recreated a new zip and Archive::Zips handles it fine. The funny thing is, that our software created the zip using the same version of Archive::Zip on it's own, before it extracted it using Archive::Zip again. Seems we are doing something wrong while creating the zip, which doesn't affect extracting the files using other zip programs, but does produce trouble in Archive::Zip when extracting more than once.

    Thanks!