Am I overseeing something? I'd like to create (possibly) large zip-files in a web-app, and from my reading of Archive::Zip, it has no means to write to a (temp) file on disk - right?
If so, any options besides system("zip ...")?

Update:
My question might be misunderstood. I'm not asking about outputting to file, but about when the file is being assembled, when the zip grows, members being added, etc. - all that happens in memory, not on disk. So a, let's say, 150MB zip will take up 150MB RAM until it is written to disk, right?
(and let's put aside that this process may take some time and a web-app would block until the zip is done... - all that better be laid off into an async process...)

Update 2:
Archive::Zip::SimpleZip can do it.
It's a wrapper around IO::Compress::Zip and offers an interface similar to Archive::Zip, only it is able to "bind" it to a real/on-disk file on OO construction, and will then write added members to disk as they arrive.
That said/found, for my webapp scenario, it's probably less ideal to build a file to disk, having disk trashing in favour of a small memory footprint, and then send_file that to the client. A better solution is probalby to use Archive::Zip::SimpleZip's ability to output a streamed zip to STDOUT, so the file is transmitted to the client while it grows, memory footprint is low, and disk IO is only read()s for adding members.

Update 3:
Archive::Zip and Archive::Zip::SimpleZip are both able to build a zip file while keeping memory footprint low. (See pmqs's answer for the why and how)
There are small differences in behaviour though, for example A::Z::SimpleZip might be more appropriate when your zip member contents are not coming from file-system.

In reply to Archive::Zip can only create zip-files in-memory, right? SOLVED by isync

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.