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

Im a little confused. Ive managed to download a zip file from one server onto my web server with a perl script, but I need to get the .csv file out of the zip file.

Ive searched this site for help unzipping a file, but I cant find anything that works. I am not able to install any new modules, so a simple solution is needed. I'd appreciate any help with this. I thought something like system ("gzip -d $file"); would work, but that does nothing, not even throwing an error.

Replies are listed 'Best First'.
Re: Unzipping a file
by jeffa (Bishop) on Aug 24, 2003 at 17:10 UTC
    You should telnet/scp (scp preferred) over to your web server and find out what compression utilities are installed. I have used unzip and bzip2 -d to successfully unzip zip files created on Windows platforms. I have found, in my experience, that gzip -d and gunzip don't handle such zip files.

    As for uncompressing from a Perl script, you would probably make your task easier by using a CPAN module instead of forking and execing a shell, something like Archive::Zip or Compress::Bzip2 (and your prerequisite "I can't install modules" is wrong - please read this.)

    Hope this helps :)

    UPDATE: (today is UPDATE day, by the way)
    Found some relevant docs in the gunzip man page:

    Files created by zip can be uncompressed by gzip only if they have a single member compressed with the 'deflation' method. This feature is only intended to help conversion of tar.zip files to the tar.gz format. To extract zip files with several members, use unzip instead of gunzip.

    UPDATE 2: (told ya)
    Disregard everything i have said about bzip2 ... i thought i had used it in the past, but that was something else ... bzip2 only decompresses zip files that have been created with bzip2.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Im still having no luck. Ive tried installing the Archive::Zip module in the way you linked to, but it didnt work.

      I cant find unzip on the system im using, but it may be there. Ive made enquiries to the hosting company, but I suppose I'll have to wait until I hear from them.
        "Didn't work" is such an incredibly useless response. What exactly did you try? What was the error message? How did you know it didn't work? Answering any of those questions is likely to get you help. Saying "It just don't work" is just likely to get you scorn and derision.