我下載了一個用於生成語言模型的perl腳本(http://www.speech.cs.cmu.edu/tools/download/quick_lm.pl)。perl <file.pl>被執行完全沒有輸出
當我做perl quick_lm.pl
,它只是終止。根本沒有輸出。
是的,我有perl安裝和
perl -v
完美的作品。我做了一個簡單的hello-world perl腳本,它執行得很好。 [附着在結束]
所以,我在
quick_lm.pl
的第一行包含print "hello";
,並試圖perl quick_lm.pl
,仍然沒有任何反應。
我甚至嘗試使用chmod 777 quick_lm.pl
給quick_lm.pl
所有權限。現在,當我做./quick_lm.pl
它給出了一個錯誤:
-bash: ./quick_lm.pl: /usr/local/bin/perl: bad interpreter: No such file or directory
我搜索這個錯誤,幾乎所有的解決方案,指着窗戶CLRF,但與他們不同,我沒有在/usr/local/bin/perl
^M
。此外,仍然perl quick_lm.pl
應該工作,對吧?
[bash.log]
[email protected]:~/dictionary$ perl quick_lm.pl
[email protected]:~/dictionary$ perl quick_lm.pl -s words.txt
[email protected]:~/dictionary$ nano quick_lm.pl
[email protected]:~/dictionary$ perl quick_lm.pl -s words.txt
[email protected]:~/dictionary$ chmod 777 quick_lm.pl
[email protected]:~/dictionary$ ./quick_lm.pl
-bash: ./quick_lm.pl: /usr/local/bin/perl: bad interpreter: No such file or directory
[email protected]:~/dictionary$ cat new.pl
#!/usr/bin/perl -w
use strict;
print "Hello World\n";
[email protected]:~/dictionary$ perl new.pl
Hello World
[email protected]:~/dictionary$
[在quick_lm.pl
開頭添加print
和它減少到該問題的一個最小的,可運行的示範之後。]
#!/usr/local/bin/perl -w
=POD
...license...
=END
use Getopt::Std;
print "hello world";
$VERBOSE = 1;
sub handler { local($sig) = @_;
print STDERR "quick_lm caught a SIG$sig -- dying\n";
exit(0);
}
foreach (qw(XCPU KILL TERM STOP)) { $SIG{$_} = \&handler; }
這不是完整的腳本,完整的腳本是在第一行中提到的鏈接。我不確定它是否與我的perl配置文件相關。正如你可能已經猜到的,我對perl沒有太多的想法。
我很欣賞你的時間和幫助:)
你的'perl'安裝在哪裏?當你輸入'command -v perl'時你會得到什麼?也許它是'/ usr/bin/perl'而不是'/ usr/local/bin/perl'? –
@EricRenouf你對這部分是正確的。它確實安裝在'/ usr/bin/perl'上。我將文件編輯爲'#!/ usr/bin/perl -w',並且它不會給出錯誤,而是再次輸出。 –
我現在不能複製你的結果,如果我複製並粘貼上面的腳本我會得到一個警告,然後「hello world」,雖然沒有一個新行,所以它可能是「隱藏」旁邊的提示 –