<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
# Demonstrates reading a zip from an IO::Scalar
# $Revision: 1.4 $
use strict;
use Archive::Zip qw(:CONSTANTS :ERROR_CODES);
use IO::Scalar;
use IO::File;

# test reading from a scalar
my $file = IO::File-&gt;new('testin.zip', 'r');
my $zipContents;
binmode($file);
$file-&gt;read($zipContents, 20000);
$file-&gt;close();
printf "Read %d bytes\n", length($zipContents);

my $SH = IO::Scalar-&gt;new(\$zipContents);

my $zip = Archive::Zip-&gt;new();
$zip-&gt;readFromFileHandle($SH);
my $member = $zip-&gt;addString('c' x 300, 'bunchOfCs.txt');
$member-&gt;desiredCompressionMethod(COMPRESSION_DEFLATED);
$member = $zip-&gt;addString('d' x 300, 'bunchOfDs.txt');
$member-&gt;desiredCompressionMethod(COMPRESSION_DEFLATED);

$zip-&gt;writeToFileNamed('test2.zip');
</pre></body></html>