#!/usr/bin/perl use strict; use warnings; use IO::Compress::Zip qw(zip $ZipError :constants) ; use diagnostics; my $zip; zip './a.txt' => \$zip, name => 'from_filename.t', AutoClose => 1, BinModeIn => 1 or die "zip failed: $ZipError\n"; my $string = ss(); zip \$string => \$zip, name => 'from_ram.t', ExtAttr => '0666', Append => 1 or die "zip failed: $ZipError\n"; open my $fh, '>','./k.zip' or die "$!"; print $fh $zip; close($fh); sub ss { return <