文章目录
- 关于 Perlbrew
- 安装 Perlbrew
- 使用 perlbrew 安装/管理 perl 版本
关于 Perlbrew
- 官网:https://perlbrew.pl
相关文档:
- App::perlbrew
https://metacpan.org/pod/App::perlbrew
Perlbrew 是一个工具,用于管理您$HOME
目录(或您指定的任何位置)中的多个perl安装。
它们是完全孤立的 perl 环境,与系统perl没有关系,彼此之间也没有关系。
有以下好处:
- 不再需要运行sudo来安装CPAN模块。
- 轻松尝试每月发布的新perl,并学习新的语言特性。
- 针对不同的perl版本测试代码。
- 在使用verndor perl(操作系统自带的)运行应用程序时,避免一些常见的危险,例如:
- 供应商perl通常有自己的用途,把它弄得太乱可能是个坏主意。升级供应商提供的CPAN模块可能已经是一个坏主意。
- 升级供应商perl通常伴随着它附带的所有CPAN模块的升级——这可能不是期望的。
- 一些供应商介绍了他们自己的perl错误,两次!
- 用于破解perl内部,因此需要在perl .git中安装来自特定提交的多个版本
- 可以只是为了跟上潮流,一直使用最新的perl版本。
安装 Perlbrew
# 下载安装
curl -L https://install.perlbrew.pl | bash
# 激活
source ~/perl5/perlbrew/etc/bashrc
Perlbrew 安装包地址:~/perl5/perlbrew/bin/perlbrew
# 查看版本
perlbrew --version
# /Users/xx/perl5/perlbrew/bin/perlbrew - App::perlbrew/0.97
# 查看帮助
perlbrew -h
# 查看更详细的帮助
perlbrew help
Usage:
perlbrew command syntax:
perlbrew <command> [options] [arguments]
Commands:
init Initialize perlbrew environment.
info Show useful information about the perlbrew installation
install Install perl
uninstall Uninstall the given installation
available List perls available to install
lib Manage local::lib directories.
alias Give perl installations a new name
upgrade-perl Upgrade the current perl
list List perl installations
use Use the specified perl in current shell
off Turn off perlbrew in current shell
switch Permanently use the specified perl as default
switch-off Permanently turn off perlbrew (revert to system perl)
exec Execute programs with specified perl environments.
list-modules List installed CPAN modules for the current Perl version in use
clone-modules Re-installs all CPAN modules from one installation to another
self-install Install perlbrew itself under PERLBREW_ROOT/bin
self-upgrade Upgrade perlbrew itself.
install-patchperl Install patchperl
install-cpanm Install cpanm, a friendly companion.
install-cpm Install cpm, a faster but still friendly companion.
install-multiple Install multiple versions and flavors of perl
download Download the specified perl distribution tarball.
clean Purge tarballs and build directories
version Display version
help Read more detailed instructions
Generic command options:
-q --quiet Be quiet on informative output message.
-v --verbose Tell me more about it.
See `perlbrew help` for the full documentation of perlbrew, or
See `perlbrew help <command>` for detail description of the command.
使用 perlbrew 安装/管理 perl 版本
1、查看可安装的 perl 版本
perlbrew available
得到如下版本信息:
# perl
perl-5.38.0
perl-5.36.1
perl-5.34.1
perl-5.32.1
...
perl-5.6.2
# cperl
2、 安装 perl
perlbrew install perl-5.36.1
安装最新的版本
perlbrew install perl-blead
如果安装失败,可执行下面代码来升级 patchperl
perlbrew install-patchperl
查看已安装的 perl
perlbrew list
# * perl-5.32.0
3、切换 perl
# 切换到 perl-5.36.1
perlbrew switch perl-5.36.1
# 在当前 shell 临时使用
perlbrew use perl-blead
4、运行测试
perlbrew exec perl myprogram.pl
perlbrew exec -- perl -E 'say $]'
# 5.032000
5、退出 perlbrew
可返回使用系统 perl
perlbrew off
使用 perlbrew switch
可继续切换为使用 perlbrew
安装 CPAN 模块
perlbrew install-cpanm
# 使用 cpanm 命令安装 CPAN 模块:
cpanm CGI::simple
2023-07-10(一)晴天