Re: Can I list contents of nested zipfile using Archive::Zip without extracting the outermost zip?

From: A. Sinan Unur (1usa_at_llenroc.ude)
Date: 01/11/04


Date: 11 Jan 2004 01:17:54 GMT

Graham Wood <dontspamme@oracle.com> wrote in news:3FFFF821.8020606
@oracle.com:

> A. Sinan Unur wrote:
>> Graham Wood <Graham.letterT.Wood@oracle.com> wrote in news:LUBLb.4
>> $mE1.141@news.oracle.com:
>>
>>
>>>I want to do this:
>>>1 open the 123456.zip
>>> read the filename.zip list (I've got this far!)
>>> foreach filename.zip (eg 123456_ar.zip)
>>> list the contents of the filename.zip
>>> }
>>>}
>>>
>>>Can I get there without extracting 1233456.zip first?
>>
>>
>> Have you looked at the docs?
...
> Yes, that's how I "got this far" already.

Fair enough. Sorry I misunderstood your question.

I am not familiar with the Archive::Zip module, but the following script
I cobbled together based on one of the examples seems to work. At first I
thought Archive::Zip::MemberRead would do the job but I ran into some
difficulties.

Here are the contents of the two zip files I used:

C:\Home> unzip -l test1.zip
Archive: test1.zip
  Length Date Time Name
 -------- ---- ---- ----
     2040 01-10-04 20:13 test.zip
 -------- -------
     2040 1 file

C:\Home> unzip -l test.zip
Archive: test.zip
  Length Date Time Name
 -------- ---- ---- ----
      398 12-04-03 23:13 dload/misc/ddd.pl
      793 11-08-03 10:30 dload/misc/g.pl
     1460 07-23-03 10:47 dload/misc/r.pl
      940 07-23-03 23:40 dload/misc/s.pl
 -------- -------
     3591 4 files

Here is the script (no error checking):

C:\Home> cat t.pl
#! perl

use strict;
use warnings;

use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use IO::Scalar;

my $zip = Archive::Zip->new('test1.zip');
my $member = $zip->memberNamed('test.zip');
my $member_contents = $member->contents();
my $member_contents_sh = IO::Scalar->new(\$member_contents);
my $member_zip = Archive::Zip->new();
$member_zip->readFromFileHandle($member_contents_sh);
print map { "$_\n" } $member_zip->memberNames();

__END__

C:\Home> t.pl
dload/misc/ddd.pl
dload/misc/g.pl
dload/misc/r.pl
dload/misc/s.pl

HTH.

Sinan.

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


Relevant Pages

  • Re: How to "unuse" Perl modules
    ... > OK, fair enough, but correct me if I am wrong but if I use fork() I ... You have been claiming that the script uses require. ... return <<EOSCRIPT; ... Sinan Unur ...
    (comp.lang.perl.misc)
  • Re: fcntl under windows
    ... > Your vendor has not defined POSIX macro F_GETFL, ... Please read the posting guidelines and post a short, ... script that still exhibits the problem you are experiencing. ... Sinan Unur ...
    (comp.lang.perl.misc)
  • Re: incrementing numbers
    ... All the DIR command did was to generate a list of all the .zip files - ... script is great and I really do appreciate it. ... So the original code is... ... unzip the files I need out of the zip. ...
    (comp.lang.awk)
  • Re: incrementing numbers
    ... The command for this is wzunzip.exe -e -s ... script is great and I really do appreciate it. ... unzip the files I need out of the zip. ... Rename the files to include yesterdays date. ...
    (comp.lang.awk)
  • Re: my own perl "dos->unix"/"unix->dos"
    ... > #setting based on filename argument. ... If you want your script to work on computers without symlinks, ... I would actually open a temp file (there is a module to do that safely ... Sinan Unur ...
    (comp.lang.perl.misc)

Loading