Installation of perl module using cpan is very handy. Previously there was a rpm for RH ‘cpam2rpm’, unfortunately, the development for this package ceased. have to go back to native cpan.
1 install cpan and its dependencies
- on ubuntu sudo apt-get install build-essential
- on fedora sudo yum install perl-CPAN
2. Configuration and installation Perl Modules as an ordinary user.
The root user had already used CPAN.pm and Perl wanted to use root’s config until I did the following. First create the .cpan directories
# These directories didn't exist on my computer mkdir $HOME/.cpan/ mkdir $HOME/.cpan/CPAN/
Then create a new MyConfig.pm in $HOME/.cpan/CPAN/
# This is so it ignores the global CPAN config that has root's
# info in it
echo "\$CPAN::Config->{cpan_home}='$HOME/.cpan';" > $HOME/.cpan/CPAN/MyConfig.pm
Then Execute a CPAN shell
perl -MCPAN -e shell
Then when in the shell type:
o conf init
to reconfigure CPAN, making sure that all of the variables point to /home/$user/.cpan/somefile instead of /home/root/.cpan/somefile
Then edit /home/$user/.cpan/CPAN/MyConfig.pm and change the makepl_arg so that it has your PREFIX line as well:
'makepl_arg' => q[INSTALLDIRS=site PREFIX=$HOME/perl/],
Finally the env variable PERL5LIB needs to point to the new module installation paths:
export PERL5LIB="$HOME/perl/share/perl/5.8.4/:$HOME/perl/lib/perl/5.8.4/";
and then you should be able to use CPAN to install modules.
I then modified the Oddmuse script so that the new module install directory was in @INC so that Oddmuse could pick up the modules. Put the following line somewhere near the top
push @INC,qw(/home/$user/perl/share/perl/5.8.4/ /home/$user/perl/lib/perl/5.8.4/);
3 Proxy for internet access
if you use proxy to access web, you need configure it too in file ~/.wgetrc
# The proxy server – proxy server:port number
http_proxy=http://PROXY.DOMAIN:port
# The account details for yum connections
proxy_username=USER
proxy_password=PASSWD
4. example
invoke the cpan command as a normal user
$cpan
But once you hit on enter for “cpan” to execute, you
be asked of some few questions. To make it simple for
yourself, answer “no” for the first question so that
the latter ones will be done for you automatically.
At the cpan prompt. now enter the commands below
make install
install Bundle::CPAN
examples of what installed below
cpan prompt> install IO::File
cpan prompt> install Net::SMTP_auth
cpan prompt> Email::MIME::Attachment::Stripper
cpan prompt> Mail::POP3Client
Hello! kggkakb interesting kggkakb site!
This surely makes great sense to anyone…