I work for a company that has a proprietary CMS software package written in Perl. We have a number of servers that run this code, and everything has been fine for a number of years and many different versions and customizations. A few months back, something changed. One of our servers started producing completely empty files for all uploads. This affected all of our code, all of our versions, and every site.
After some time debugging and testing, I finally found the problem. Apparently some code was updated, either Perl itself or one of its packages, and that caused my CGI object to be recylced before the upload code ran. When the CGI object gets recylced, all the file handles are closed resulting in reading and saving an empty file.
The solution was deceptively simple. All I had to do was store the CGI object in a persistent variable that has scope throughout the end of the program execution.
Did I help you?