2013-03-20 30 views
1

我在Windows 7上使用xampp 1.8.1并希望将其用于perl,但是当我执行最简单的hello world perl脚本时,它会给我一个错误500有人知道我做错了什么吗?这是我的“Hello World脚本:xampp 1.8.1 perl无法正常工作并出现投影错误500

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

由于提前,

+0

你有你的目录和这个文件的所有正确的文件模式?你有没有正确的URL在这个文件的路径?可能需要更多信息才能获得任何帮助... – Lucas 2013-03-20 15:12:46

+0

[Wed Mar 20 16:17:22.205165 2013] [win32:error] [pid 5420:tid 1656] [client :: 1:52122] AH02102:C:/ xampp /htdocs/test.pl不可执行;确保解释的脚本具有“#!”要么 ”'!”第一行 [Wed Mar 20 16:17:22.205165 2013] [cgi:error] [pid 5420:tid 1656](9)错误的文件描述符:[client :: 1:52122] AH01222:不知道如何产卵子进程:C:/xampp/htdocs/test.pl – kasperB 2013-03-20 15:18:24

+0

这是我从我的apache服务器上的error.log文件所说的 – kasperB 2013-03-20 15:20:09

回答

2

更改家当线实际却指向你的Perl路径,例如:

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

你可以,如果引用它必需:

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

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

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

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所在 此外,您还可以保存一个Perl文件第i个.pl扩展名。 pm,.cgi。但对于浏览器使用,我更喜欢.cgi扩展名。

我认为这对你有帮助。

相关问题