2013-03-20 28 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擴展名。

我認爲這對你有幫助。

相關問題