如果在Ubuntu18.04上安装了两个PERL版本,我该如何使新的Perl版本成为我的默认版本?

发布于 2025-02-10 08:30:59 字数 1219 浏览 2 评论 0原文

我的计算机上安装的默认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.

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

 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/usr/local/bin/code> :

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

在使用Perl -V检查Perl版本时,我仍将Perl 5.26.0作为已安装版本。

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

我是Linux的新手。任何帮助都将受到赞赏。

The default perl version installed on my machine is 5.26.1. I found this out by using the following command:

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.

I installed the newest perl version from source using the following commands present on the link (https://www.cpan.org/src/):

 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

I tried changing the path to /usr/local/bin/ using the following command but it didn't work:

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

On checking the perl version using perl -v, I am still getting perl 5.26.0 as the installed version.

How can I make perl 5.36.0 as my default version?

I am new to Linux. Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你是我的挚爱i 2025-02-17 08:30:59
-Dprefix="$HOME/localperl"

表示Perl位于$ home/localperl/bin/perl。您可以使用此验证

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

,正确的路径添加是$ home/localperl/bin

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

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

您已经知道如何做前者,但是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
-Dprefix="$HOME/localperl"

means that perl is located at $HOME/localperl/bin/perl. You can verify this using

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

As such, the correct PATH addition is $HOME/localperl/bin.

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

You might want to consider perlbrew. It's a tool that can be used to install different versions of perl, and to manipulate the PATH to switch between them.

You already know how to do the former, but perlbrew also applies patches to older versions of Perl to fix problems that prevent them from being installed.

But it seems you might get benefit from the latter.

$ 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文