<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
use strict;
use Archive::Zip qw(:CONSTANTS :ERROR_CODES);
use IO::Scalar;
use IO::File;

# test writing to a scalar
my $zipContents = '';
my $SH          = IO::Scalar-&gt;new(\$zipContents);

my $zip = Archive::Zip-&gt;new();
my $member = $zip-&gt;addString('a' x 300, 'bunchOfAs.txt');
$member-&gt;desiredCompressionMethod(COMPRESSION_DEFLATED);
$member = $zip-&gt;addString('b' x 300, 'bunchOfBs.txt');
$member-&gt;desiredCompressionMethod(COMPRESSION_DEFLATED);
my $status = $zip-&gt;writeToFileHandle($SH);

my $file = IO::File-&gt;new('test.zip', 'w');
binmode($file);
$file-&gt;print($zipContents);
$file-&gt;close();

</pre></body></html>