in reply to Premature end of script headers error

According to your error messages, I suspect the exec bit is not turned on, do: chmod +x (or whatever is required so the apache User has permissions to run it.)

I would also uncomment CGI::Carp until things work, just to ensure that is compilable.