in reply to Error while Zipping a Directory

I haven't tried reproducing your problem, but I notice that you don't filter '..' and '.' from @filearray which may cause unexpected results. Also, readdir returns entries relative to $directory which means you don't have a valid path for each entry unless $directory happens to be the current directory. Most often you will need to prefix each entry with $directory: "$directory\\$file".

Premature optimization is the root of all job security