Hello,

I have to extract a zip file exactly in the order the files are present in the zip, but some of the files need the contents of other files in the zip which may or may not already have been processed to be processed itself. I tried to solve this by first getting all members I need for processing the special files and if one of those special files is to be processed I just wanted to extract the formerly retrieved files as needed.

The problem is that the formerly retrieved files could already have beend extracted and processed on their own and that every attempt to extract the same member object a second time to another filename failes with AZ_STREAM_END. I just use extractToFileNamed and can't find anything in the docs where is stated that multiple extractions of the same member is not allowed or possible.

Because of the error I tried using endRead() and rewindData() before extracting the member a second time but this didn't change anything. It's really a lot easier, and the files need to be extracted twice are really small, to extract some members twice, rather than storing which member already has been extracted and reuse those files and cleaning up later etc.

The only thing which seems to work, because the algorithm I wanted to change used to work this way before, is to extract all the files I need two times, store the extracted files and recreate the zip-Object using Archive::Zip->new()->read() a second time to process all members. This time they are only extracted ones and the formerly extracted files used as needed.

Is there really no easy way to just extract a zip member twice?


In reply to unable to extract same file twice using Archive::Zip by Pickwick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.