繁体   English   中英

如果在 Ubuntu18.04 上安装了两个 perl 版本,我怎样才能将新的 perl 版本设为默认?

[英]If there are two perl versions installled on Ubuntu18.04, how can I make the new perl version my default?

我机器上安装的默认 perl 版本是 5.26.1。 我通过使用以下命令发现了这一点:

perl -v
 
This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi
(with 71 registered patches, see perl -V for more detail)

Copyright 1987-2017, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

我使用链接( https://www.cpan.org/src/ )上的以下命令从源代码安装了最新的 perl 版本:

 wget https://www.cpan.org/src/5.0/perl-5.36.0.tar.gz
 tar -xzf perl-5.36.0.tar.gz
 cd perl-5.36.0
 ./Configure -des -Dprefix=$HOME/localperl
 make
 make test
 make install

我尝试使用以下命令将路径更改为/usr/local/bin/但它不起作用:

 export PATH=$HOME/usr/local/bin/:$PATH

在使用perl -v检查 perl 版本时,我仍然将 perl 5.26.0 作为安装版本。

如何将 perl 5.36.0 作为我的默认版本?

我是 Linux 新手。 任何帮助表示赞赏。

-Dprefix="$HOME/localperl"

意味着perl位于$HOME/localperl/bin/perl 您可以使用验证这一点

"$HOME/localperl/bin/perl" -v

因此,正确的 PATH 添加是$HOME/localperl/bin

export PATH="$HOME/localperl/bin:$PATH"

您可能需要考虑perlbrew 它是一个工具,可用于安装不同版本的perl ,并操纵PATH在它们之间切换。

您已经知道如何进行前者,但是perlbrew还对旧版本的 Perl 应用补丁来修复阻止它们安装的问题。

但似乎你可能会从后者中受益。

$ perl -v | grep 'This is'
This is perl 5, version 36, subversion 0 (v5.36.0) built for x86_64-linux-thread-multi

$ perlbrew use 5.34t

$ perl -v | grep 'This is'
This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux-thread-multi

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM