in reply to Re^2: How to upgrade local module using -MCPAN?
in thread How to upgrade local module using -MCPAN?

Update: chromatic confirmed my suspicion that CPAN is a core module. I won't bore you with a descrition of the tortuous path that led me to doubt this and then write the blather below about installing CPAN.pm from scratch; it'll suffice to say that it is besides the point.


Well, in that case what you want to do is pretty much what -MCPAN will do right out of the box, at least for Unix-like systems (which the only kind I have experience with; keep this in mind as you read what follows).

Of course, first you need to install CPAN.pm itself, and to be honest, this is one of those things, like making sourdough bread, where one seeds the process once and then each subsequent iteration is based on the results of the previous one. Similarly, once one installs CPAN.pm the first time, it takes care of all subsequent installations of new versions of itself. This is a long way of saying that it has been a very long time since I had to install CPAN.pm on a system that didn't already have some version of CPAN.pm installed. I guess that you will have to download the CPAN.pm distribution file and follow the standard

perl Makefile.PL make make test make install
sequence from within the directory where you unpacked the CPAN.pm distribution.

On my system (a Debian Linux box), the main configuration file for CPAN.pm lives in /etc/perl/CPAN/Config.pm. There are a whole bunch of options that can be specified in this file. I will have to refer you to the docs for the details: CPAN.

Once you have CPAN.pm installed and properly configured, then just run

% perl -MCPAN -e shell
or simply invoke the cpan script (which should have been installed in your PATH). Just make sure that you have sufficient privileges to write to the global directories. In fact the lines above may need to be something like
% sudo perl -MCPAN -e shell
or simply
% sudo cpan
Once inside the CPAN shell, just use the install to install whatever you want:

% perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.7601)
ReadLine support enabled

cpan> install Sex

If you have configured CPAN.pm properly, the above command will fetch, unpack, build, test, and install schwern's Sex.pm, for example.

the lowliest monk

Replies are listed 'Best First'.
Re^4: How to upgrade local module using -MCPAN?
by Anonymous Monk on May 26, 2005 at 14:51 UTC
    I'm sorry Sir. But I know that already. My problem is how can I 'upgrade' the module. Say Sex.pm version 1.0 to Sex.pm version 2.0.

      Sorry, I should have made it explicit that the install command usually installs the most current version available in CPAN. So "install" amounts to "upgrade" if you already have an older version of the module installed in your system.

      But if you knew about "install" already, then I am surprised you did not know what I just wrote above, which leads me to suspect that there is some aspect of your question that I am missing entirely.

      the lowliest monk