2

I'm beginning to write a simple Perl program on my Mac, and I understand that the first line needs to be the location of Perl itself, every example or tutorial I find tells me the first line should be:

"#!/usr/bin/perl"

However, with that there, I attempt to run the file under localhost and I get this error:

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.

Anyone have any idea why this is happening?

Thanks in advance, and let me know if any more information is needed!

P.S. if it helps, when I execute the command: "perl -v" it tells me

This is perl, v5.10.0 built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail)

fullOfQuestions
  • 21
  • 1
  • 2
  • 3
  • 1
    Could you edit your question and paste the contents of your Perl script? And how are you running the script? This looks like a system error, not a Perl error per se. –  May 04 '11 at 00:48
  • `#!/usr/bin/perl` is the correct path for 10.6 – Erik May 04 '11 at 00:56
  • 2
    From the [Stack Overflow Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq): [How can I troubleshoot my Perl CGI script?](http://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script) – daxim May 04 '11 at 07:33

2 Answers2

5

As Erik said, /usr/bin/perl is the standard location for Perl on OSX. You can also verify this by running which -a perl from terminal (this will list all instances of Perl on your path).

Can you run your script from the command-line, i.e. ./<myscript>.pl? It's possible that you haven't made the script executable.

Eric Seidel
  • 2,781
  • 2
  • 17
  • 18
  • Interesting. When I run `which -a perl` it does show that as the location of Perl on my machine. When I try to run it from the command line it tells me that I don't have permission, and when I sudo it, I get the error: `sudo: ./hello.pl: command not found` How do I make it executable? Also, thanks in advance for all the help guys, I really appreciate it! – fullOfQuestions May 04 '11 at 21:51
  • `chmod +x hello.pl` will make the script executable for all users. As for the sudo error, I'm not sure, could potentially be sudo's way of telling you the file wasn't executable. – Eric Seidel May 05 '11 at 02:48
2

#!/usr/bin/perl is the correct path for 10.6. If you're running from the webserver, your first line before any output should be a HTML header. You may have forgotten one?

#!/usr/bin/perl

use CGI; 
print CGI->header('text/html'); 
print "hello world";
Erik
  • 20,526
  • 8
  • 45
  • 76