tags:

views:

141

answers:

4

Hello! When I installed perl from the source the first nice surprise was that without doing something all module installed from now on were available to the new perl. Since I didn't find one module on cpan that comes with my OS I have to use for some scripts the onboard-perl. For one of these scripts I would like to install Text::Format or Text::Autoformat (didn't find the docu for that module on cpan). My question: how can I tell cpan to install the module this one time for the OS-distro-perl?

+2  A: 

/path/to/system/perl -MCPAN -e shell

Alexandr Ciornii
This is the same thing as just running `cpan`.
brian d foy
brian d foy: `cpan` will run cpan shell for first perl in PATH, not for perl that is needed.
Alexandr Ciornii
Alexandr: see effectiveperlprogramming.com/blog/92
brian d foy
A: 

I'm assuming you want to simply install modules to a different location and then run them from that location -- your question wasn't too clear to me.

Read the perldoc fully on local::lib. It would be a major failure on my part to try to write that better. This is also the most recent and advanced way to achieve this task. If another solution doesn't reference this module, then my personal suggestion would be to avoid it like the plague.

Evan Carroll
+1  A: 

Each Perl installation has its own idea of where libraries should "live", which the CPAN module uses as a guide for where to perform its installations. You can see what these values are by executing perl -V, and look for the value of @INC (at the bottom). If you invoke CPAN with a different Perl (e.g. your system-installed Perl), you will automatically install modules into that Perl's preferred location:

/usr/bin/perl -MCPAN -e shell

or to simply install one module without having to invoke the CPAN shell explicitly:

/usr/bin/cpan <modulename>

There are also CPAN configuration options available where you can temporarily or permanently change the install location, but this should not be necessary in your case.

Ether
I've seen "perl -MCPAN -e shell" sometimes, but I didn't pay attention to it until now. ( I always used "cpan" and then "install Modul::Name" );
sid_com
I don't see how any of this speaks to the question he asked, "change the target for module installation", this all deals with PERL5LIB which while applicable has nothing to do with where CPAN installs stuff. With that said, congrats on reading into the question.
Evan Carroll
And, AFAIK cpan/cpanp do not in any distro use the last value of @INC but instead what ever is in the distributions configuration of them.
Evan Carroll
@Evan: different CPANs install into different locations. Using the 'cpan' executable that corresponds with the perl you want to install for will "just work", using the configurations that have already been set up at install time.
Ether
cpan will use whatever perl installed it. You might want to see my Effective Perler post on making links to per-version tools: http://www.effectiveperlprogramming.com/blog/92
brian d foy
Running cpan with no arguments already puts you in the CPAN.pm shell.
brian d foy
A: 

There isn't a special way to tell cpan to install modules in a new location for just the one invocation. That feature, however, is on my to do list, along with local::lib support. I truly understand your pain and want the same feature. I just need the time (or the patch) to make it work.

Until then, you have to enter the CPAN.pm shell and change the values for mbuild_arg and makefilepl_arg as noted in perlfaq8: How do I keep my own module directory?:


When you build modules, tell Perl where to install the modules.

For Makefile.PL-based distributions, use the INSTALL_BASE option when generating Makefiles:

perl Makefile.PL INSTALL_BASE=/mydir/perl

You can set this in your CPAN.pm configuration so modules automatically install in your private library directory when you use the CPAN.pm shell:

% cpan
cpan> o conf makepl_arg INSTALL_BASE=/mydir/perl
cpan> o conf commit

For Build.PL-based distributions, use the --install_base option:

perl Build.PL --install_base /mydir/perl

You can configure CPAN.pm to automatically use this option too:

% cpan
cpan> o conf mbuild_arg "--install_base /mydir/perl"
cpan> o conf commit
brian d foy