Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux教程 >> Linux操作系統下安裝Perl腳本語言的方法

Linux操作系統下安裝Perl腳本語言的方法

日期:2017/2/7 16:58:52      編輯:Linux教程

  Linux和perl都屬於自由軟件,將二者結合真是妙不可言。


  遵循以下步驟一般就可安裝好 perl ,perl 就能在 linux 下歡唱。


  1 取得最新版本的 perl,當前版本為 5.6.0,即 stable.tar.gz。


  2 解文件包:

gunzip stable.tar.gz
tar xvf stable

  得到目錄 perl-5.6.0


  3 在目錄 perl-5.6.0 下安裝 perl:

rm -f config.sh Policy.sh
sh Configure -de
make
make test
make install

config.sh Policy.sh 為以前安裝時的配置文件,新安裝或升級安裝時需要將其刪除。

sh Configure -de 安裝使用默認配置,一般而言將會 ok 。

安裝完成後 perl 所在目錄為 /usr/local/lib/perl5, perl 執行文件在 /usr/local/bin 中。

4 關於 .html 文件

安裝 perl 時不能自動安裝 .html 文件, 在 perl-5.6.0 目錄中有一個installhtml 文件, 執行 perl installhtml --help 可得到使用幫助,使用installhtml可將 .pod 及 .pm 文件編譯得到相應的 .html 文件文件, 它的具體使用請自己看。

下面是我所寫的一個具有類似功能的程序。

simple_find("5.6.0");# 含 .pm 文件的源目錄
use Pod::Html;
sub simple_find{
$sourth="/usr/local/lib/perl5/5.6.0html/"; #含 .html的目標目錄
my ($input)=@_;
my $file;
$ddir=$sourth.$input;
$cont=`file $ddir`;
if ($cont !~/$ddir\:\sdirectory/){
`mkdir $ddir`;
}
opendir(md,$input);
my @file=readdir(md);
closedir(md);
@pfile= grep(m/\.pm/,@file);
my @dfile= grep(!m/\.pm/,@file);
@dfile=grep(!m/^\./,@dfile);

foreach $pfile(@pfile){
$pfile=~/\.pm/;
$dfile=$`;
$sfile=$input."/".$pfile;
$dfile=$sourth.$input."/".$dfile."\.html";
pod2html(
"--infile=$sfile",
"--outfile=$dfile");
}
foreach $file(@dfile){
$vale=$input."/".$file;
$cont=`file $vale`;
if ($cont=~/$vale\:\sdirectory/){
simple_find($vale);
}
}
}

使用以上程序得到一個與源目錄結構一致的目標目錄,包含相應的. html文件。

注:使用以上兩種方法都會產生不能轉化某行類錯誤,其實它無關大局,可以忽略。

5 模塊安裝

gunzip Module.tar.gz
tar xvf Moudle.tar

轉到相應目錄

perl Makefile.PL
make
make test
make install

安裝完成後模塊在 /usr/local/lib/perl5/site_perl 目錄中, . html文件不能自動安裝,需使用前面介紹方法進行安裝。

Copyright © Windows教程網 All Rights Reserved