cpanm安裝及Perl模組安裝教程_perl

來源:互聯網
上載者:User

cpanm是安裝Perl模組的最方便的方法。自動下載安裝依賴包。使用CPAN shell或下載源碼包安裝模組,遇到大量依賴關係,非常頭痛。下面就是一例:

安裝MongoDB模組

複製代碼 代碼如下:

# perl Makefile.PL
Warning: prerequisite Class::Method::Modifiers 0 not found.
Warning: prerequisite Data::Types 0 not found.
Warning: prerequisite DateTime 0 not found.
Warning: prerequisite DateTime::Tiny 0 not found.
Warning: prerequisite ExtUtils::MakeMaker 6.59 not found. We have 6.30.
Warning: prerequisite File::Slurp 0 not found.
Warning: prerequisite File::Temp 0.17 not found. We have 0.16.
Warning: prerequisite JSON 0 not found.
Warning: prerequisite Moose 0 not found.
Warning: prerequisite Test::Exception 0 not found.
Warning: prerequisite Test::Warn 0 not found.
Warning: prerequisite Tie::IxHash 0 not found.
Warning: prerequisite Try::Tiny 0 not found.
Warning: prerequisite boolean 0 not found.
Writing Makefile for MongoDB

1. 安裝cpanm

cpanm其實是一個可執行檔而已。將它下載到bin目錄,然後添加執行許可權就可以了。

複製代碼 代碼如下:

# wget http:
//xrl.us/cpanm -O /usr/bin/cpanm; chmod +x /usr/bin/cpanm

2. 使用cpanm安裝模組

複製代碼 代碼如下:

# cpanm -h
  -v,--verbose              Turns on chatty output
  -q,--quiet                Turns off the most output
  --interactive             開啟互動配置(required for Task:: modules)
  -f,--force                強制安裝
  -n,--notest               Do not run unit tests
  --test-only               只測試不安裝
  -S,--sudo                 sudo to run install commands
  --installdeps             只安裝相依模組
  --showdeps                只顯示依賴資訊
  --reinstall               重新安裝
  --mirror                  指定鏡像url (e.g. http://cpan.cpantesters.org/)
  --mirror-only             只從鏡像下載
  --prompt                  Prompt when configure/build/test fails
  -l,--local-lib            Specify the install base to install modules
  -L,--local-lib-contained  Specify the install base to install all non-core modules
  --self-contained          Install all non-core modules, even if they're already installed.
  --auto-cleanup            Number of days that cpanm's work directories expire in. Defaults to 7

  Examples:
  cpanm Test::More                                          # install Test::More
  cpanm MIYAGAWA/Plack-0.99_05.tar.gz                       # full distribution path
  cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz           # install from URL
  cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz            # install from a local file
  cpanm --interactive Task::Kensho                          # Configure interactively
  cpanm .                                                   # install from local directory
  cpanm --installdeps .                                     # install all the deps for the current directory
  cpanm -L extlib Plack                                     # install Plack and all non-core deps into extlib
  cpanm --mirror http://cpan.cpantesters.org/ DBI           # use the fast-syncing mirror

參數名直接為模組名稱

如,安裝MongoDB模組

複製代碼 代碼如下:

# cpanm MongoDB
--> Working on MongoDB
Fetching http://www.cpan.org/authors/id/F/FR/FRIEDO/MongoDB-0.702.0.tar.gz ... OK
Configuring MongoDB-0.702.0 ... OK
==> Found dependencies: DateTime, Tie::IxHash, Data::Types, DateTime::Tiny, Class::Method::Modifiers, boolean, Moose, File::Slurp, Try::Tiny, Test::Exception, ExtUtils::MakeMaker, Test::Warn, File::Temp, JSON
--> Working on DateTime
......  //自動解決相依模組

為了加快下載速度, 可以指定使用鏡像,並只從鏡像下載:

複製代碼 代碼如下:

# cpanm --mirror http:
//mirrors.163.com/cpan --mirror-only MongoDB

3. 刪除模組

安裝App::pmuninstall模組:

複製代碼 代碼如下:

# cpanm App::pmuninstall

4.刪除模組

複製代碼 代碼如下:

# pm-uninstall MongoDB

MongoDB.so: undefined symbol: HeUTF8 問題解決方案參見:http://www.jb51.net/article/56285.htm

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.