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