Switching to the system Perl using perlbrew

寵の児 提交于 2019-11-28 20:48:02

To have perlbrew manage an installation of perl that wasn't installed by perlbrew, pick a name ("system" in my example) and create a link to its bin directory as follows:

cd "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"
mkdir perls/system
ln -s /usr/bin perls/system/bin

It will now appear in perlbrew list

$ perlbrew list
  ...
  system (5.10.1)
  5.18.2t
* 5.20.0t
  ...

And you'll be able to use perlbrew use and perlbrew switch.

$ perl -V:version
version='5.20.0';

$ perlbrew switch system

$ perl -V:version
version='5.10.1';

$ bash -ic 'perl -V:version'
version='5.10.1';

This works best with installations that have the same installbin, installvendorbin (if applicable) and installsitebin directories, as returned by

perl -V:'install.*bin'

By the way, a similar approach can be used to create aliases for perlbrew installs. For example,

 ln -s 5.26.1 perls/5.26           # Point to the latest release of a version.
 ln -s 5.26.1 perls/project_name   # Point to the install used by a project.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!