0

My scripts require a new version of perl, which I have installed into a local directory, to avoid corrupting the packaged version of perl that comes with Debian.

I configured and installed a tarball of perl with:

Configure -des -Dprefix=/root/perl
make
make install 

Then I called cpan with:

/root/perl/bin/perl -MCPAN -e shell 

Every time I install a module I do this:

$/root/perl/bin/perl -MCPAN -e shell
cpan[2]> install Getopt::Long
cpan[2]> install WWW::Mechanize
cpan[2]> install File::Find::Rule

With a system version of perl I used to be able to do this from Bash:

$cpan -i DBI

How can I use a similiar command from bash, without needing to open up the cpan shell each time I need to install a module?

Edit: I should have read the documentation more thoroughly. The solution is:

/root/perl/bin/perl -MCPAN -e 'install Getopt::Long'

Or (Thanks, suddenmoves)

/root/perl/bin/cpan -i Getopt::Long

Joel G Mathew
  • 7,561
  • 15
  • 54
  • 86
  • 1
    Or You could just create an alias for quick access to the local cpan shell. Thanks, that's useful. – Grzegorz Piwowarek Apr 30 '13 at 07:33
  • 2
    Also worth looking at perlbrew to install custom perls and cpanm as an installer: https://metacpan.org/module/GUGOD/App-perlbrew-0.62/bin/perlbrew https://metacpan.org/module/MIYAGAWA/App-cpanminus-1.6909/bin/cpanm – Richard Huxton Apr 30 '13 at 09:52
  • +1 for Perlbrew. It takes care of all this for you. – Quentin Apr 30 '13 at 13:48

1 Answers1

2

If you've got a full install of perl under /root/perl, is there not a /root/perl/bin/cpan executable you can run?