Check your server's error logs, or use
CGI::Carp with
fatalsToBrowser so that you can actually see whether the script is dieing at the
chdir stage, the
rename stage, or somewhere else. Once you do that you'll probably find the answer to this question without too much additional guidance.
I would suspect improper permissions, or maybe an invalid path.