2010-03-27

Perl - How to list installed modules

A note for myself. This is how to list out what perl modules are installed.
Way 1 :
perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'

Way 2 :
perldoc perllocal


*** these are all taken from http://perldoc.perl.org/perlmodlib.html

Das Vidanya !!!

2010-03-20

Perl - How to install perl module without root or super user

By default, perl modules installed through cpanX (cpanm, cpanp & cpan) utilities are install into system wide perl directory. Although this will make the module available through out all users on this box, it also means if there's a problem with particular module, it affects all users. Some other problem hit me as well :

Problem 1 - bloated with perl modules :
Some modules installed because it was needed to fulfill some dependencies (not necessary useful though), testing purpose or other reasons. This resulted the system wide perl directory is bloated with modules that aren't used as often as it should & should be removed. Removing modules in perl aren't easy as removing packages through a package manager. Because a typical package manager will check for dependencies to make sure that removing 1 package won't break another package.

Removing perl modules typically means manually remove the .pm files (or directory) in perl system wide directory. And this means there is a risk that removing a module might break some program or modules that depends on it.

Problem 2 - no root privileges :
In a hosting environment, normally one doesn't have root or sudo account, which installing CPAN modules needs it to add or change files in perl system wide directory. How nice if a normal users can have their own perl module directory.

Problem 3 - development environment :
Developers likes to setup individual perl projects to test & work on different environment. Naturally sets of modules that can be install into few different directories to serve as environment, switching between these directories are ideal for this situation. In this case, messing up an environment doesn't means messing up the entire perl modules.

Given the above situation, local::lib fits into the picture by solving the problems. Local::lib creates a directory resides in ~/ and cpan modules are install into here afterwards. Local::lib does that by changing the environment parameters @INC & system's $PATH variable.

The below instruction uses the "bootstrap" method of local::lib installation. This is useful on hosting environment where no access for root or sudo execution to install local::lib perl module.

2010-03-12

Perl - How to install CPAN module, the easier way

Following IronMan Challenge posts not only for the sake of seeing What Color of Hair & Shirt ends up with Matt but the posts have been much enlightening. Recently in IronMan Challenge, there's been much talk about one of Miyagawa's project, App::cpanminus. Basically, cpanminus is a tool to install perl module from CPAN, without the verbosity of cpan|cpanplus, which also means, more newbie friendly. :)

The beauty of cpanminus is, it does not ask dozens of question before it installs. Instead, cpanminus will use the most suitable defaults & start downloading dependencies and install it. By default, cpanminus will not tell every action and result on the screen, which "scare" less.

In short, cpanminus improves or makes perfect the experience of installing modules from CPAN. Since the first time trying cpanminus, love it and loving it more seems inescapable :p

*** Some assumptions, perl 5.8 at least exist.

Enough talking, here's how to install cpanminus :