xampp 1.8.1 perl无法正常工作并且输出错误500

时间:2013-03-20 15:08:56

标签: perl xampp mod-perl httpexception

我在Windows 7上使用xampp 1.8.1并希望将它用于perl,但是当我执行最简单的hello world perl脚本时它会给我一个错误500.有人知道我做错了什么吗?这是我的'hello world script:

 #!/usr/bin/perl
print "Hello World.\n";

提前致谢,

2 个答案:

答案 0 :(得分:2)

将shebang行更改为实际指向Perl路径,例如:

#!c:/Strawberry/perl/bin/perl.exe

如有必要,您可以引用它:

#!"c:/Program Files/Perl/perl.exe"

请注意,在Perl中,您甚至可以在Windows上使用正斜杠作为目录(这是首选,因为它可以避免混乱的转义问题)。

在Windows上,shebang行中的路径通常不用于执行。因此,惯例通常是使用#!/usr/bin/perl来与Linux兼容。但是,Apache 实际上使用此路径,因此需要相应地设置。

答案 1 :(得分:1)

正确的代码是:

#!C:\xampp\perl\bin\perl.exe

# The above line is perl execution path in xampp

# The below line tells the browser, that this script will send html content.
# If you miss this line then it will show "malformed header from script" error.
print "Content-ype: text/html\n\n";
print "Hello world."

在xampp中,perl执行路径是C:\ xampp \ perl \ bin \ perl.exe 此外,您可以保存扩展名为.pl,.pm,.cgi的perl文件。但是对于浏览器使用,我更喜欢.cgi扩展名。

我认为这会对你有帮助。