do I have to use a temporary file??
If your zip data is small enough to fit in memory, then you do not have to use a temporary file. Archive::Zip supports reading from a file handle, but the file handle must be seekable.
Since perl 5.8.0, one can open a string. Unfortunately, the resulting file handle is not compatible with Archive::Zip.
But IO::String gives compatible file handles, so you can use something like the following.
#!/usr/bin/perl
use strict;
use warnings;
use Archive::Zip;
use IO::String;
my $zipfile = "test.zip";
open(ZIP, "<", "$zipfile") or die "$zipfile: $!";
my $zipdata = do { local $/; <ZIP>; };
close(ZIP);
my $io = IO::String->new($zipdata);
my $zip = Archive::Zip->new();
my $status = $zip->readFromFileHandle($io);
print "\$status = $status\n";
foreach my $member ($zip->members()) {
print "member: " . $member->fileName() . "\n";
}
close(ZIP);
|