Hold the sarcasm, I think he's actually asking how to extract a file to a specific directory, and not just with a different name. So the solution is not that trivial.

I think indeed either extractMember or extractMemberWithoutPaths, where you first construct the full path for the new file, from the old member name.

Actually, I think Archive::Zip could use an edit, where you could pass a path to a directory (either an existing directory or a path that ends in a slash/backslash/other directory separator), which would then serve as a root dir for the extraction. It currently doesn't do that, the optional path must include the file name.

So, the OP needs to add some code constructing the new path name out of the member name, and use that as a second parameter to extractMember.

You can retrieve the internal path for a member by using the snippet

$name = $member->fileName();

Do ZIP archives use absolute or relative paths? If it's relative path, it'll use the current directory as the root dir. In that case it's easy: just chdir to the directory that you want to use as the root for the decompressed archive.


In reply to Re^2: how to extract zip files to specified location by bart
in thread how to extract zip files to specified location by Anonymous Monk

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.