设为首页 收藏本站
查看: 1144|回复: 0

[经验分享] perl安装模块到自己的home ( install perl module without root)

[复制链接]

尚未签到

发表于 2015-12-25 15:51:14 | 显示全部楼层 |阅读模式
use local::lib to install perl modules in your home directory ?
  https://metacpan.org/pod/local::lib + http://search.cpan.org/
By default local::lib installs itself and the CPAN modules into ~/perl5.
Windows users must also see "Differences when using this module under Win32".


  •   Download and unpack the local::lib tarball from CPAN (search for "Download" on the CPAN page about local::lib). Do this as an ordinary user, not as root or administrator. Unpack the file in your home directory or in any other convenient location.

  •   Run this:

      perl Makefile.PL --bootstrap
      If the system asks you whether it should automatically configure as much as possible, you would typically answer yes.
      In order to install local::lib into a directory other than the default, you need to specify the name of the directory when you call bootstrap, as follows:

      perl Makefile.PL --bootstrap=~/foo
  •   Run this: (local::lib assumes you have make installed on your system)

      make test && make install
  •   Now we need to setup the appropriate environment variables, so that Perl starts using our newly generated lib/ directory. If you are using bash or any other Bourne shells, you can add this to your shell startup script this way:

      echo '[ $SHLVL -eq 1 ] && eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >>~/.bashrc
      If you are using C shell, you can do this as follows:

      /bin/csh
    echo $SHELL
    /bin/csh
    echo 'eval `perl -I$HOME/perl5/lib/perl5 -Mlocal::lib`' >> ~/.cshrc
      If you passed to bootstrap a directory other than default, you also need to give that as import parameter to the call of the local::lib module like this way:

      echo '[ $SHLVL -eq 1 ] && eval "$(perl -I$HOME/foo/lib/perl5 -Mlocal::lib=$HOME/foo)"' >>~/.bashrc
      After writing your shell configuration file, be sure to re-read it to get the changed settings into your current shell's environment. Bourne shells use . ~/.bashrc for this, whereas C shells use source ~/.cshrc.




http://learn.perl.org/faq/perlfaq8.html

How do I keep my own module/library directory?
  When you build modules, tell Perl where to install the modules.
  If you want to install modules for your own use, the easiest way might be local::libhttp://onexin.iyunv.com/source/plugin/onexin_bigdata/file:///E:/Jason/youdaoyunbiji/itech001@126.com/49590bc6bafa4275be95df01294978e7/external.v1.png, which you can download from CPAN. It sets various installation settings for you, and uses those same settings within your programs.
  If you want more flexibility, you need to configure your CPAN client for your particular situation.
  For Makefile.PL-based distributions, use the INSTALL_BASE option when generating Makefiles:

    perl Makefile.PL INSTALL_BASE=/mydir/perl
  You can set this in your CPAN.pm configuration so modules automatically install in your private library directory when you use the CPAN.pm shell:

    % cpan
cpan> o conf makepl_arg INSTALL_BASE=/mydir/perl
cpan> o conf commit
  For Build.PL-based distributions, use the --install_base option:

    perl Build.PL --install_base /mydir/perl
  You can configure CPAN.pm to automatically use this option too:

    % cpan
cpan> o conf mbuild_arg "--install_base /mydir/perl"
cpan> o conf commit
  INSTALL_BASE tells these tools to put your modules into /mydir/perl/lib/perl5. See "How do I add a directory to my include path (@INC) at runtime?" for details on how to run your newly installed modules.
  There is one caveat with INSTALL_BASE, though, since it acts differently from the PREFIX and LIB settings that older versions of ExtUtils::MakeMakerhttp://onexin.iyunv.com/source/plugin/onexin_bigdata/file:///E:/Jason/youdaoyunbiji/itech001@126.com/49590bc6bafa4275be95df01294978e7/external.v1.png advocated. INSTALL_BASE does not support installing modules for multiple versions of Perl or different architectures under the same directory. You should consider whether you really want that and, if you do, use the older PREFIX and LIB settings. See the ExtUtils::Makemakerhttp://onexin.iyunv.com/source/plugin/onexin_bigdata/file:///E:/Jason/youdaoyunbiji/itech001@126.com/49590bc6bafa4275be95df01294978e7/external.v1.png documentation for more details.
  

How do I add a directory to my include path (@INC) at runtime?
  Here are the suggested ways of modifying your include path, including environment variables, run-time switches, and in-code statements:

the PERLLIB environment variable
    $ export PERLLIB=/path/to/my/dir
$ perl program.pl
the PERL5LIB environment variable
    $ export PERL5LIB=/path/to/my/dir
$ perl program.pl
the perl -Idir command line flag
    $ perl -I/path/to/my/dir program.pl
the lib pragma:
    use lib "$ENV{HOME}/myown_perllib";
the local::libhttp://onexin.iyunv.com/source/plugin/onexin_bigdata/file:///E:/Jason/youdaoyunbiji/itech001@126.com/9a9941def41b482d9a0580d092347fde/external.v1.png module:
    use local::lib;
use local::lib "~/myown_perllib";

  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-156312-1-1.html 上篇帖子: Perl One-liners学习笔记3 下篇帖子: perl 哈希(hash)学习笔记(一)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表