Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Can't find EOCD signature Archive::Zip

by webchalkboard (Scribe)
on Apr 08, 2005 at 12:33 UTC ( [id://445999]=perlquestion: print w/replies, xml ) Need Help??

webchalkboard has asked for the wisdom of the Perl Monks concerning the following question:

Hello

I am having problems with Archive:Zip, I am utilising code I found on this site here:

Create/Extract Zip Archives

I am trying to create a script which automatically downloads and unzips a file, then parses the contents and loads into a database. I can download the file ok using LWP::Simple and getstore(), but the unzipping bit is proving troublesome.

I get the following error message.

format error: can't find EOCD signature Archive::Zip::Archive::_findEndOfCentralDirectory('Archive::Zip::Arch +ive=HASH(0x8e87c00)','IO::File=GLOB(0x9196204)') called at /usr/lib/p +erl5/site_perl/5.8.3/Archive/Zip.pm line 955 Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH +(0x8e87c00)','IO::File=GLOB(0x9196204)','tooled-up.gz') called at /us +r/lib/perl5/site_perl/5.8.3/Archive/Zip.pm line 929 Archive::Zip::Archive::read('Archive::Zip::Archive=HASH(0x8e87c00)',' +tooled-up.gz') called at zip.pl line 13 Error reading zip file. at zip.pl line 13.

Does anybody have a clue what's wrong? The file works fine, i've ftped it over from the unix server i'm running the script on, to my windows PC and unzipped it manually and the file contains a foler within which is the text file i'm interested in.

If it's any help here is a fragment of my code.

if (is_error(getstore($geturl, $zipdestination))) { print "ERROR - Failed to write CSV to destination<br/> +"; next; } # extract a zip file print "Extracting $zipdestination...\n"; my $zip = Archive::Zip->new(); die 'Error reading zip file.' if $zip->read($zipdestination) ! += AZ_OK; my @members = $zip->members(); foreach my $element (@members) { print "$element\n"; $zip->extractMember($element); } print "Done!\n";

Any ideas?

Thanks, Tom

Learning without thought is labor lost; thought without learning is perilous. - Confucius
WebChalkboard.com | For the love of art...

Replies are listed 'Best First'.
Re: Can't find EOCD signature Archive::Zip
by edbewald (Beadle) on Apr 08, 2005 at 16:41 UTC
    I'm a self taught programmer who loves perl (but am decidedly lacking in most aspects). Anyway, I ran into a similar situation recently when trying to unzip gzipped files. I finally tracked down my problem on CPAN's ARCHIVE::ZIP::FAQ

    ******

    Q: Can I use Archive::Zip to extract Unix gzip files?

    A: No.

    There is a distinction between Unix gzip files, and Zip archives that also can use the gzip compression.

    Depending on the format of the gzip file, you can use Compress::Zlib, or Archive::Tar to decompress it (and de-archive it in the case of Tar files).

    You can unzip PKZIP/WinZip/etc/ archives using Archive::Zip (that's what it's for) as long as any compressed members are compressed using Deflate compression.

    ******

    I ended up just using system calls, though I know the wise men on this sight could suggest other modules that would work.

    If I am way off on this, please excuse my misunderstanding.

    Update: formatting changes

    Eddie

      Ive just found this site and you've helped me out massivley Eddie, much appreciated oh wise one. Look forward to helping out fellow monks where I can. Matthew.

      Work : the curse of the drinking classes
      existem : bristol tonight

Re: Can't find EOCD signature Archive::Zip
by polettix (Vicar) on Apr 08, 2005 at 13:01 UTC
    Have you tried to unzip it directly inside the Unix server? Moreover, what compression method does this zip file use? Archive::Zip only handles deflate/inflate method from zlib, so it fails when other methods are used (tough I don't know with what error exactly).

    Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")

    Don't fool yourself.
Re: Can't find EOCD signature Archive::Zip
by knowmad (Monk) on Apr 13, 2006 at 15:07 UTC

    I've just recently come across this problem with a CGI script. I am using PAR to load my libraries. The PAR file was created using the zip utility in Linux. I could unzip the file without a problem. I could run the zipcheck.pl script that is in the examples directory of the Archive::Zip package without a problem.

    The very weird solution turned out to be renaming my cgi script to include a file extension (I was trying to use it without a file extension). It may be worth adding that the cgi script with no extension worked fine under Debian testing but was failing on my production server which is running Ubuntu Breezy.

    William

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://445999]
Approved by RolandGunslinger
Front-paged by RolandGunslinger
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-03-28 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found