use IO::Compress::Zip qw(:all);my @files = ('error.log', 'access.log', 'ssl_request.log');
my $path = "/var/log/apache22";
print "Content-Type:application/zip\n";
print "Content-Disposition: attachment; filename=\"filename.zip\"\n\n";
my $z;
foreach my $file (@files) {
if ($z) {
$z->newStream(Name => $file, Method => ZIP_CM_STORE);
} else {
$z = new IO::Compress::Zip "-", Name => $file, Method => ZIP_CM_STORE;
}
open(FILE, "<", "$path/$file");
binmode FILE;
my ($buf, $data, $n);
while (($n = read FILE,$data, 1024) != 0) {
$z->print($data);
}
close(FILE);
}
$z->close;
exit;