ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:

I want to install perl modules in the CentOS using yum. I tried yum install perl-Search-Elasticsearch. Its saying no such module. I tried

yum install perl-Excel-Writer-XLSX Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.webwerks.com * epel: epel.mirror.angkasa.id * extras: centos.webwerks.com * rpmforge: miroir.univ-paris13.fr * updates: centos.webwerks.com Package perl-Excel-Writer-XLSX-0.84-1.el7.noarch already installed and + latest version Nothing to do

But it is an older version. For this I updated my yum also. Still the problem is same. I need to update my perl library for this??? Then how to update the library ????

perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-li +nux-thread-multi

Replies are listed 'Best First'.
Re: Install perl packages using yum
by Corion (Patriarch) on Jul 22, 2016 at 11:00 UTC

    You will need to talk to the person who packages Perl modules for your distribution. Not every Linux distribution automatically packages the latest Perl modules. Often new modules need to go through several stages of release testing before becoming available. Some modules are not packaged at all.

    This is more a question about CentOS packaging and less about Perl.

    Maybe the Elasticsearch package has a different name for CentOS or nobody has packaged it. That's why people usually recommend that you use perlbrew or something similar to maintain your own private Perl installation for the applications you write for yourself.

Re: Install perl packages using yum
by marto (Cardinal) on Jul 22, 2016 at 11:06 UTC

    If your OS package manager doesn't have the modules/versions you need install them via cpan, or manually:

    cpan Search-Elasticsearch

    Manually (download, extract etc):

    perl Makefile.PL make make test make install

      I know this is an old post but this information is not readily available.

      On a packaged managed system like CentOS, please do not use cpan to install packages. It is not an enterprise solution since most companies will not let you install software from the Internet for production systems and you will just have to figure out some other way to package your software anyway. The correct method is to build your own RPMs with `cpanspec`.

      $ wget https://cpan.metacpan.org/authors/id/J/JM/JMCNAMARA/Excel-Write +r-XLSX-1.03.tar.gz $ cpanspec -b Excel-Writer-XLSX-1.03.tar.gz

      Unfortunately, for Excel-Writer-XLSX, cpanspec did not pick up the installed man page and script in /usr/bin.

      > error: Installed (but unpackaged) file(s) found: > /usr/bin/extract_vba > /usr/share/man/man1/extract_vba.1.gz

      So, I had to manually add those paths to the SPEC %files section and try again.

      %files %{_mandir}/man1/* %{_bindir}/*

      Then rebuild it

      $ rpmbuild -ba perl-Excel-Writer-XLSX.spec --define "_sourcedir $PWD"

      At this point you now have an RPM that you could put on your yum repository and it will be available for all of your systems.

      > Wrote: ~/rpmbuild/SRPMS/perl-Excel-Writer-XLSX-1.03-1.el7.stopllc.sr +c.rpm > Wrote: ~/rpmbuild/RPMS/noarch/perl-Excel-Writer-XLSX-1.03-1.el7.stop +llc.noarch.rpm
      Or install it with yum from the command line
      sudo yum install ~/rpmbuild/RPMS/noarch/perl-Excel-Writer-XLSX-1.03- +1.el7.stopllc.noarch.rpm #only command that needs root permissions

      Bonus points

      Sign your rpms

      rpm --addsign ~/rpmbuild/RPMS/noarch/perl-Excel-Writer-XLSX-1.03-1.e +l7.stopllc.noarch.rpm

      Build your own yumrepo with createrepo. If your path is /var/www/html/yumrepo then your yumrepo will be at http://127.0.0.1/yumrepo/ requires `yum install httpd`

      sudo mkdir -p /var/www/html/yumrepo/ #only first time sudo mv ~/rpmbuild/RPMS/noarch/perl-Excel-Writer-XLSX-1.03-1.el7.sto +pllc.noarch.rpm /var/www/html/yumrepo/ sudo createrepo /var/www/html/yumrepo # new or deleting rpm +s sudo createrepo --update /var/www/html/yumrepo # if only adding rpms

      Configure your yum repo on the client systems (change 127.0.0.1 to your host name)

      /etc/yum.repos.d/my.repo [my-repo] name=My Repo baseurl=http://127.0.0.1/yumrepo/ enabled=1 gpgcheck=0

      Clean up your older rpm repo versions with repomanage

      repomanage --keep=2 --old /var/www/html/yumrepo | xargs -P4 -I'{}' / +bin/rm '{}` # delete versions older than the last two versions createrepo /var/www/html/yumrepo + # rebuild the yum index

        I tend to avoid using the OS perl whenever possible. When dealing with the system perl, the OS package manager should use used.

        "It is not an enterprise solution since most companies will not let you install software from the Internet for production systems and you will just have to figure out some other way to package your software anyway."

        This depends upon your environment. We have no direct internet connections. A cpan mirror (crated using minicpan on a system which does have interwebs access) allows us to build what we need before deploying fleet wide.

        $ wget https://cpan.metacpan.org/authors/id/J/JM/JMCNAMARA/Excel-Write +r-XLSX-1.03.tar.gz $ cpanspec -b Excel-Writer-XLSX-1.03.tar.gz

        Here you are still just downloading software from the internet, repackaging it and later deploying it, albeit with the OS package manager, Archive::Zip isn't core so I think you'd have to use cpanspec --follow to ensure you satisfy dependencies:

        "If you are feeling really lucky (or maybe crazy), you can also have cpanspec build a binary rpm by passing the -b (or --build) option. As of version 1.66, you can also use --follow to have cpanspec fetch any build dependencies that aren't already available."

        https://fedoraproject.org/wiki/Perl/cpanspec.