Perl Tutorials - Herong's Tutorial Examples - v6.03, by Herong Yang
"cpan" Command Line Tool
This section provides a quick introduction on the 'cpan' command, which uses the CPAN module to provide similar functionalities as the CPAN 'shell'.
Most Perl installations on Linux computers also provides a command line tool called "cpan". It uses the CPAN module and offers almost the same functionalities as the CPAN "shell".
Here are some examples of using the "cpan" command to install and manage Perl modules:
List installed modules:
herong$ cpan -l PadWalker 2.5 DateTime 1.66 Ref::Util::XS 0.117 Devel::Caller 2.07 Devel::LexAlias 0.05 Test::LeakTrace 0.17 Test::LeakTrace::Script undef Package::Stash::XS 0.30 Class::XSAccessor 1.19 Class::XSAccessor::Heavy 1.19 Class::XSAccessor::Array 1.19 Digest::SHA1 2.13 Params::Util 1.102 Params::Util::PP 1.102 DateTime::Types 1.66 DateTime::Infinite 1.66 DateTime::PPExtra 1.66 ...
Install a given Perl module with "root" privilege:
herong$ sudo cpan -i Imager ... Installing /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Imager.pm Installing /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Imager/Regops.pm Installing /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Imager/Draw.pod ... Running Build test t/00.load.t ............... 1/1 # Testing Parse::RecDescent 1.967015 t/00.load.t ............... ok t/01.basics.t ............. ok t/autotree.t .............. ok ... All tests successful. ...
Display information for a given Perl module:
herong$ cpan -D Imager Imager ------------------------------------------------------------------------- (no description) T/TO/TONYC/Imager-1.028.tar.gz /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Imager.pm Installed: 1.028 CPAN: 1.028 up to date Tony Cook (TONYC) tony@develop-help.com
Search for CPAN modules with a keyword:
herong$ cpan -x image Imager Page dmake aze ...
Table of Contents
Data Types: Values and Variables
Expressions, Operations and Simple Statements
Name Spaces and Perl Module Files
Hard References - Addresses of Memory Objects
Objects (or References) and Classes (or Packages)
Typeglob and Importing Identifiers from Other Packages
String Built-in Functions and Performance
File Handles and Data Input/Output
Open Directories and Read File Names
File System Functions and Operations
Socket Communication Over the Internet
XML::Simple Module - XML Parser and Generator
SOAP::Lite - SOAP Server-Client Communication Module
Perl Programs as IIS Server CGI Scripts
CGI (Common Gateway Interface)
XML-RPC - Remote Procedure Call with XML and HTTP
RPC::XML - Perl Implementation of XML-RPC
Integrating Perl with Apache Web Server
CGI.pm Module for Building Web Pages
LWP::UserAgent and Web Site Testing
Converting Perl Script to Executable Binary
►CPAN (Comprehensive Perl Archive Network)
Install Perl Module with CPAN Shell