in reply to Examples of Archive::Zip

Acccording to the docs, the following code should do what you want (untested of course):
my $zip = Archive::Zip->new(); $zip->addFile($file); $zip->writeToFileHandle(*STDOUT);
I didn't see an option to get it to just give you the zip file in a scalar or something, so you'll have to either write your own FakeFileHandleAccumulator or get one off cpan (IO::ALL looks like it might do it easily), but for just sending the output of your zip file via a cgi script, write to file handle should do what you need.

Replies are listed 'Best First'.
Re: Examples of Archive::Zip
by Anonymous Monk on Apr 06, 2004 at 08:57 UTC

    Since s/he is planning to output this to the browser, you'd think the writeToFileHandle() method will suffice (to STDOUT). If s/he does wind up needing it in a scalar (for some perverse reason, I can think of no good reason for needing this), s/he could use something like this to get the contents of $zip into $scalar:

    # recent perl's: open( my $fh, '>', \my $scalar ) or die "open failed: $!"; $zip->writeToFileHandle($fh); # recent & odler perl's: use IO::Scalar; # or: # use IO::String (apparently more recent than IO::Scalar) my $fh = IO::Scalar->new(\my $scalar); $zip->writeToFileHandle($fh);