use File::Copy copy(badfile,tempfile); zip->addfile(tempfile); unlink(tempfile);