Linux 與 Perl 皆為自由軟體,結合使用相得益彰。以下步驟助你在 Linux 完成 Perl 安裝與設定。
取得最新版本(當前為 5.6.0,即 stable.tar.gz)。
gunzip stable.tar.gz tar xvf stable.tar
解壓後得到 perl-5.6.0 目錄。
進入目錄執行:
rm -f config.sh Policy.sh sh Configure -de make make test make install
說明:
config.sh、Policy.sh 避免舊設定衝突sh Configure -de 採用預設設定,通常即可正常運作/usr/local/lib/perl5,執行檔在 /usr/local/bin安裝不自動產生 .html 文件。原始目錄提供 installhtml 工具,執行 perl installhtml --help 查看用法。以下提供一個自訂腳本,可複製目錄結構並同步產生 .html:
simple_find("5.6.0");
use Pod::Html;
sub simple_find {
my $sourth = "/usr/local/lib/perl5/5.6.0html/";
my ($input) = @_;
my $file;
my $ddir = $sourth . $input;
my $cont = `file $ddir`;
if ($cont !~ /$ddir: directory/) { `mkdir $ddir`; }
opendir(my $md, $input);
my @file = readdir($md);
closedir($md);
my @pfile = grep(/\.pm$/, @file);
my @dfile = grep(!/\.pm$/, @file);
@dfile = grep(!/^\./, @dfile);
foreach my $pfile (@pfile) {
$pfile =~ /\.pm$/;
my $dname = $`;
my $sfile = $input . "/" . $pfile;
my $outfile = $sourth . $input . "/" . $dname . ".html";
pod2html("--infile=$sfile", "--outfile=$outfile");
}
foreach my $file (@dfile) {
my $vale = $input . "/" . $file;
my $cont = `file $vale`;
if ($cont =~ /$vale: directory/) { simple_find($vale); }
}
}
注意:執行過程可能出現無法轉換某些行的錯誤,通常可忽略。
gunzip Module.tar.gz tar xvf Module.tar cd Module目錄 perl Makefile.PL make make test make install
模組安裝至 /usr/local/lib/perl5/site_perl,.html 文件需自行用上述方法產生。