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


In reply to Re^3: How to upgrade local module using -MCPAN? by tlm
in thread How to upgrade local module using -MCPAN? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.