use IO::Compress::Zip qw(zip $ZipError); my $zip = new IO::Compress::Zip \*STDOUT or print STDERR "IO::Compress::Zip failed: $ZipError\n"; foreach my $file (@files) { ... do some stuff to the file ... now add file to the archive } $zip->close;