Perl Tutorials - Herong's Tutorial Examples - v6.03, by Herong Yang
CPAN Local Directories and Files
This section provides an introduction of local directories and files used when installing Perl modules from the CPAN repository.
If you are using the CPAN shell or "cpan" command to install and manage Perl modules, it will create a number of local directories and files:
The working directory - .cpan, located in your home directory. It contains sub-directories and files to support the CPAN working sessions:
The lock file - .cpan/.lock, located in your home directory. It is used as locker to ensure that there is only a single CPAN session running.
home/herong/.cpan/.lock
Installation locations - Located in /usr/local directory. That's where Perl modules will be installed.
Perl uses 3 sets of variables to control where modules are installed:
1. "perl" - For standard modules included with Perl itself.
# build specific modules installarchlib='/usr/lib/x86_64-linux-gnu/perl/5.26'; # generic modules installprivlib='/usr/share/perl/5.26';
2. "vendor" - For modules installed by the provider of your Perl engine.
# build specific modules installvendorarch='/usr/lib/x86_64-linux-gnu/perl5/5.26'; # generic modules installvendorlib='/usr/share/perl5';
3. "site" - For modules installed using CPAN.
# build specific modules installsitearch='/usr/local/lib/x86_64-linux-gnu/perl/5.26.1'; # generic modules installsitelib='/usr/local/share/perl/5.26.1';
You can use the "-V" option to view Perl variables:
herong$ perl -V:'install.*' installarchlib='/usr/lib/x86_64-linux-gnu/perl/5.26'; installprivlib='/usr/share/perl/5.26'; installvendorarch='/usr/lib/x86_64-linux-gnu/perl5/5.26'; installvendorlib='/usr/share/perl5'; installsitearch='/usr/local/lib/x86_64-linux-gnu/perl/5.26.1'; installsitelib='/usr/local/share/perl/5.26.1'; ...
You can get a list of installed Perl modules from the CPAN repository by looking at the installation locations:
herong$ ls -l /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 drwxrwxr-x 37 root root 4096 Sep 2 09:49 auto drwxrwxr-x 3 root root 4096 Sep 2 09:47 Class drwxrwxr-x 2 root root 4096 Sep 2 09:50 DateTime -r--r--r-- 1 root root 137251 Feb 18 2025 DateTime.pm drwxrwxr-x 2 root root 4096 Sep 2 09:46 Devel drwxrwxr-x 2 root root 4096 Jul 9 2023 Digest drwxrwxr-x 3 root root 4096 Sep 2 09:44 List ... herong$ ls -l /usr/local/share/perl/5.26.1 drwxrwxr-x 2 root root 4096 Sep 2 09:48 Capture drwxrwxr-x 5 root root 4096 Sep 2 09:49 Class drwxrwxr-x 3 root root 4096 Sep 2 09:44 CPAN drwxrwxr-x 4 root root 4096 Sep 2 09:49 DateTime drwxrwxr-x 3 root root 4096 Sep 2 09:46 Devel drwxrwxr-x 2 root root 4096 Jul 9 2023 Digest -r--r--r-- 1 root root 11225 Aug 24 2021 Digest.pm drwxrwxr-x 3 root root 4096 Sep 2 09:46 Dist ...
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