[PERL]
"Premature End of Script Headers" means that either the permissions for the script are off or the output doesn't begin with "Content-Type: text/htmlnn" Try setting the permissions of the script to 755 and the output files to 666.
[PHP]
Not having a matching number of { and } - usually indicated by an error on the last line of your code.
Forgetting to put a ; at the end of the line - usually indicated by an error or the following line.
+Forgetting that the $ character do not to be escaped in a string delimited by some simple quotes.