No such file or directory Error

I performed a clean install of Linux (Ubuntu 10.04) + Apache 2 + Perl 5.10.1, and then uploaded a program I wanted to use.

When I loaded up the page in my web browser, I immediately got this error:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

I checked the Apache error log, and it said this:

(2)No such file or directory: exec of '/cgi-bin/myfile.cgi' failed
Premature end of script headers: myfile.cgi

What? “No such file or directory”?? I *know* the file is there.

I checked the file, I made sure it had “#!/usr/bin/perl” at the beginning, etc. Google lead me on page after page where people either found no solution, or the solution was they simply spelled something wrong. I made sure everything was correct. Path, spelling, etc.

I finally found a page that helped me:

http://www.linuxquestions.org/questions/linux-newbie-8/perl-2-no-such-file-or-directory-exec-of-599269/

I had to change the first part of my file to read #!/usr/bin/perl -w.