use IO::Scalar; my $memory_file = ''; #scalar as a file , my $memfile_fh = IO::Scalar->new(\$memory_file); #filehandle to the scalar # write to the scalar $memory_file my $status = $zip->writeToFileHandle($memfile_fh); $memfile_fh->close;