20090313 where perl modules live - plembo/onemoretech GitHub Wiki

title: Where perl modules live link: https://onemoretech.wordpress.com/2009/03/13/where-perl-modules-live/ author: lembobro description: post_id: 361 created: 2009/03/13 16:39:08 created_gmt: 2009/03/13 16:39:08 comment_status: open post_name: where-perl-modules-live status: publish post_type: post

Where perl modules live

As everyone knows, Ubuntu is based on Debian Linux, and mostly follows that distribution’s conventions for placement of various binaries and data on the filesystem.

Very unfortunately, this holds true for how perl and its modules get installed on Ubuntu.

Here is the output of perl -e "print @INC" on one of my x86_64 Intrepid (Ubuntu 8.10) boxes:

/etc/perl/usr/local/lib/perl/5.10.0/usr/local/share/perl/5.10.0/usr/lib/perl5/usr/share/perl5/usr/lib/perl/5.10/usr/share/perl/5.10/usr/local/lib/site_perl.root

OK, lets clean that up a bit:

/etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5/usr/share/perl5/usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl.root

That’s a lot of places for various pieces of a scripting language. Let’s compare with what you’d see under Red Hat Enterprise Linux 4.x (RHEL 4, x86_64):

/usr/lib/perl5/5.8.5/i386-linux-thread-multi/usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0

No joy here either. How about an old Sun Solaris 8 (SPARC) box with perl installed from an equally old sunfreeware package?

/usr/local/lib/perl5/5.6.1/sun4-solaris /usr/local/lib/perl5/5.6.1 /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl.t

Yuck.

So basically the way perl gets installed on most distributions sucks. Big time.

So how do you find where a particular module’s code has been installed given this kind of confusion?

There are at least 2 ways I know of short of doing a ‘find’ from /usr/lib/perl5 and (for 64-bit systems) /usr/lib64/perl5.

First, use the instmodsh script (example is from RHEL 5 x86_64).

[me@example ~]$ **instmodsh** Available commands are: l - List all installed modules m - Select a module q - Quit the program cmd? **m Net::LDAP** Available commands are: f [all|prog|doc] - List installed files of a given type d [all|prog|doc] - List the directories used by a module v - Validate the .packlist - check for missing files t - Create a tar archive of the module h - Display module help q - Quit the module Net::LDAP cmd? **d all** all directories in Net::LDAP are: /usr/lib/perl5/site_perl/5.8.8/Bundle/Net /usr/lib/perl5/site_perl/5.8.8/LWP/Protocol /usr/lib/perl5/site_perl/5.8.8/Net /usr/lib/perl5/site_perl/5.8.8/Net/LDAP /usr/lib/perl5/site_perl/5.8.8/Net/LDAP/Control /usr/lib/perl5/site_perl/5.8.8/Net/LDAP/Extension /usr/lib/perl5/site_perl/5.8.8/Net/LDAP/Intermediate /usr/share/man/man3 Net::LDAP cmd?

Under perl 5.10.0 another way to do this is to probably use the [cpan](http://perldoc.perl.org/cpan.html) utility, with the “-D” switch as described in the doc. For example, if you wanted to find the location where Net::LDAP is installed (bold indicating path added by me):

root@mybox:~# **cpan -D Net::LDAP** CPAN: Storable loaded ok (v2.18) Going to read /var/tmp/.cpan/Metadata Database was generated on Thu, 12 Mar 2009 22:26:57 GMT Net::LDAP ————————————————————————- Interface to LDAP Protocol (RFC1777) G/GB/GBARR/perl-ldap-0.39.tar.gz **/usr/share/perl/5.10.0/Net/LDAP.pm** Installed: 0.39 CPAN: 0.39 up to date Perl LDAP mailing list (PLDAP) [email protected]

As you can see, this also gives you the location on CPAN of the original package tarball, as well as the current version installed. You can run cpan in noninteractive mode like this without first having an installation profile configured for the user you’re logged in as.

Those running an earlier version of CPAN could upgrade to the latest. To do this, run the following:

perl -MCPAN "install CPAN"

Allow it to install the latest version of modules like Test::Harness, but under no circumstances install CPAN::Bundle or any other bundle. On your next invocation of cpan after upgrading you’ll be prompted to re-answer some of the standard config questions, including the location of mirror sites. Get that from the old config, which for RHEL is located under /usr/lib/perl5/5.8.8/CPAN/Config.pm.

Copyright 2004-2019 Phil Lembo