in reply to Perl can't write files
Check which user the httpd is running as.
ps -ef | grep apache [download]
It is EXTREMELY unwise to run httpd and especially CGI scripts as root. So most people don't.