The documentation doesn't seem hard to follow, it just doesn't seem to specify, that I can see, a few things. First being, how do you set the name of the zip file? It shows how to read an already made zip file and it give this next line as an example, thing is it doesn't explain if this is how you assign the name of the zip file itself. It just gives you the code.
my $zip = Archive::Zip->new('somefile.zip');
I don't want to keep a zip file of the files, I'd rather have it temporary and forgotten at the time it loads. I know I can unlink the zip file afterwards, but it looks like it might have what I'm looking for. This is hard for me to understand, will this create a temporary zip file that will disappear when the script ends?
Archive::Zip::tempName( [$tmpdir] ) Create a unique name for a temp file, in the given directory or in the + first one of: /tmp $ENV{TMPDIR} $ENV{TEMP} . Archive::Zip::tempFile( [$tmpdir] ) Create a uniquely named temp file. It will be returned open for read/w +rite. If $tmpdir is given, it is used as the name of a directory to c +reate the file in. If not given, creates the file in the first direct +ory found in this list: /tmp $ENV{TMPDIR} $ENV{TEMP}
Basically all I want to do is when they go to my script, it makes a zip file for a given $filename and pushes it as a download box so they can download it. So not only do I need to create a zip file and remove it (or not ever store it) but at the same time push it to the user to download.

Can someone show me an example of how I would do any part of this? Compression isn't needed, just the fact it's a zip file will work. This is what I've got so far.

my $member = "/home/name/www/images/sunset.png"; my $zip = Archive::Zip->new('newfile.zip'); $zip->addMember( $member );

In reply to Examples of Archive::Zip 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.