如何将默认的 perl 安装更改为 macports 安装的安装

发布于 2025-01-01 09:23:14 字数 484 浏览 0 评论 0原文

我通过macports安装了perl5.14。

通过输入

which perl

我得到

/usr/bin/perl

How do I Change the perl to point the macports one。

我的 .profile 是:

    # MacPorts Installer addition on 2012-02-02_at_14:42:32: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

I installed perl5.14 via macports.

By typing

which perl

I get

/usr/bin/perl

How do I change the perl to point the macports one.

My .profile is:

    # MacPorts Installer addition on 2012-02-02_at_14:42:32: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

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

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

发布评论

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

评论(4

浅紫色的梦幻 2025-01-08 09:23:14

也许 perl 端口未激活?尝试:

$ sudo port activate perl5

Maybe the perl port isn't active? try:

$ sudo port activate perl5
一抹苦笑 2025-01-08 09:23:14
sudo port install perl5 +perl5_14
sudo port install perl5 +perl5_14
迷离° 2025-01-08 09:23:14

您需要重新启动终端才能使导出生效。作为一种快速但混乱的解决方法,您始终可以像这样调用 perl:
/opt/local/bin/perl 请记住将其也放入 Perl 脚本中。另外,与 unix 不同,我发现在安装到本地目录时总是必须使用 sudo。

Macports 非常适合安装 Mac 上未安装的所有非 Perl 库,但是它不太适合安装 Perl 模块,因为它依赖于它的端口,你不能真正使用 CPAN 来安装 Perl 模块。安装。 perlbrew 可以在 Mac 上运行,并且是一个更好的解决方案。但如果您仍然想使用 Macports 安装非 Perl 库,那么您就会遇到问题。我用 .profile 解决了这个问题,如下所示:

source ~/perl5/perlbrew/etc/bashrc
# export PATH=/opt/local/bin:/opt/local/sbin:$PATH

请注意评论。当我打开终端时,第一行给我我的 perlbrew Perl。当我想使用 Macports 安装库时,我交换注释并重新启动终端,然后我就拥有了 Macports Perl。当然,这意味着我的机器上需要两个 Perls,并且它们都需要是相同的版本,但我对此没有任何问题。

You need to re-launch terminal for the export to take effect. As a quick but messy workaround you can always invoke perl like this:
/opt/local/bin/perl Remember to put that in your Perl scripts as well. Also, unlike unix I find I always have to use sudo when installing to a local directory.

Macports is great for installing all those non-Perl libraries that aren't installed on the Mac, however it is not so great for installing Perl modules as it is dependant on there being a port of it, you can't really use CPAN to install. perlbrew does work on the Mac and is a much better solution. But if you still want to use Macports to install non-Perl libraries you hit a problem. I solved it with a .profile like this:

source ~/perl5/perlbrew/etc/bashrc
# export PATH=/opt/local/bin:/opt/local/sbin:$PATH

Note the comment. The first line gives me my perlbrew Perl when I open terminal. When I want to use Macports to install libraries I swap the comment around and re-launch terminal and I then have Macports Perl. Of course this means I need two Perls on my machine, and they both need to be the same version but I don't have any problems with this.

通知家属抬走 2025-01-08 09:23:14

由于我没有使用 Mac,所以无法准确回答您的问题。然而,许多 Perl 用户/开发人员现在使用 perlbrew 来安装较新版本的 Perl 并管理在它们之间进行选择。我相当有信心它可以在 Mac 上运行。如需了解更多信息,请访问网站CPAN

Not being on a Mac, I cannot answer your exact question. However, many Perl users/developers now use perlbrew to install newer versions of Perl and manage choosing between them. I am fairly confident that it works on Mac. Read more at the website or CPAN.

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