in reply to Premature end of script header error
Check your server error logs (or use CGI::Carp's fatalsToBrowser if you don't have easy access to the logs). I would assume you're die'ing (permission issues) and hence not seeing the error.