運行Perl程序———hello.plx

昨天把第一個python程序運行出來了,很容易。

今天運行Perl程序的時候,發現運行不了,書裏面記載的是unix裏面的運行方式,在百度裏面找了找,好幾個網頁裏面寫的都是亂七八糟的東西。

去了一趟官方文檔原來真有。

To run your Perl scripts, enter the following command at the command prompt:

perl -w yourscriptname.pl

Where yourscriptname.pl is the name of the script you want to run. If you are using Windows and have associated the extension of the file with Perl, typing yourscriptname.pl (that is, without calling perl first) will also launch the script.


隨便用了一個文本編輯器寫了一個入門的程序。

#!/usr/bin/perl
print "Hello, world!\n";


保存爲hello.plx 

在windows下的run裏面寫cmd按回車,然後進入hello.plx的所在的文件目錄裏面。

perl -w hello.plx

出現運行了結果(當然我事先安裝了activePerl,當前在Perl的官方網站上推薦的幾款免費的編譯器也可以):

Hello, world

感覺很爽。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章