Are you on a plan that comes with CGI ?
First the web server looks at the extension to see if its CGI file or not. If your domain is not configured to run CGI, then it doesn't care at this point and simply reads the file as if it were a plain file.
If the extension is a CGI extension, then the web server looks for the magic number and file permissions. If you have this wrong, you'll get a 500 Internal Server Error.
The script file and the directory it is in should both be chmod to 755. If you chmod a directory to 777, then other users could create files in that directory, so its not a good idea to do that. The last 5 means other users can read and execute, but not write. 7 means they can do all three.
Perl / MySQL / HTML CSS