Updated: 28 September 2026 · Applies to: AlmaLinux 9 / Rocky Linux 9

RHEL/CentOS 7 are end of life; these steps are for AlmaLinux 9 / Rocky Linux 9. Installing CPAN modules as RPM packages keeps them under the control of dnf. First check whether the module is already packaged: dnf install 'perl(Module::Name)'. If not, build a package with cpanspec.

1. Install the tools

dnf install epel-release
dnf config-manager --set-enabled crb
dnf install cpanspec rpm-build rpmdevtools perl-generators gcc make
rpmdev-setuptree              # creates ~/rpmbuild (run as a normal user)

2. Create the spec file and build

cd ~/rpmbuild/SOURCES
cpanspec --packager "Your Name <you@example.com>" Some::Module   # downloads the source from CPAN and writes the spec
mv perl-Some-Module.spec ../SPECS/
cd ../SPECS
rpmbuild -ba perl-Some-Module.spec

If the build stops because of missing dependencies, install them (dnf builddep perl-Some-Module.spec) or build those modules first in the same way.

3. Install the package

dnf install ~/rpmbuild/RPMS/noarch/perl-Some-Module-*.rpm     # or RPMS/x86_64 for modules with C code

Tip: Build packages as a normal user, never as root. Keep the spec files so you can rebuild when the module is updated.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket