Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell what modules were originally provided with the specific Perl installation on a machine?

How can I tell what modules were originally provided with the specific Perl installation on a machine?

(This is not a duplicate of: How can I tell if a Perl module is core or part of the standard install? ( "How can I tell if a Perl module is core or part of the standard install?" ) - it is in fact a spin-off question from it )

I am looking for what came with the installation originally, what modules were provided as part of that installation, what was built-in. NOT what has been installed since then.

I would like this to work with any Perl version.

I want to be able to do this:

  • using a script within a Perl program itself/command on the machine that has the installation. So for this I would be relying upon the installation to have a record in some form as to what it has originally.
  • on the downloaded package before I do the install. Ask it what modules it has.

The reasons why I want to do this is:

  • I want to know what modules I can expect as default when writing software to run on a machine with the Perl installation, and what modules I would need to add which aren't default
  • if I keep the original installer image/package OR know how to get the exact thing again online, then I have a repeatable consistent Perl installation for several machines with the knowledge of what modules will be present and what modules will not.
  • my Perl software will have a well defined deployment procedure as it is easy to define exactly what is required by the software
  • I may not be able to just update/upgrade the Perl version easily due to policies in place in my organisation (that's just the way it is, I don't want a side discussion on this). Such policy can be justified as there is always a risk upgrading to new software that can outweigh the benefits. Developers therefore need to know what they can expect to be available.

The reason why I ask this question is because, for any Perl version, there appears not to be an automated way of finding out the overall standard installation defining what modules you can expect to be present in your default installation on your machine - see question: How can I tell if a Perl module is core or part of the standard install? ( "How can I tell if a Perl module is core or part of the standard install?" )

The Perl versions cannot be relied upon to tell you what modules are present or not. Sure, there might be documentation online that tells you. But I need an automated way of doing this on the release I download/install. Even the same Perl version on different Linux/Unix distributions can be different.

like image 392
therobyouknow Avatar asked Jan 18 '10 11:01

therobyouknow


2 Answers

In general you can't. You'll have a lot less frustration if you accept that and approach the problem from a different angle. Module::CoreList provides a list of what should be included in all installations as a bare minimum but vendors aren't required to adhere to that and most distributions include many modules that aren't part of the core. Barring building your own database of what was included in which version of each distribution -- a daunting task -- there's not much hope. Note that even for modules that came with a distribution the installed version might be different.

I can see a few different ways to approach this:

  1. If you know your target at development time (e.g. a specific version of ActivePerl) you can make decisions based on that.
  2. For the general case deploy your application like a module and specify dependencies. e.g. use Module::Build and list prerequisites in the requires section of the Build.pl script. The cpan shell can follow and resolve dependencies automatically.
  3. If you want to sidestep the issue entirely use PAR and Par::Packer to create self-contained deployment bundles.
like image 142
Michael Carman Avatar answered Oct 20 '22 11:10

Michael Carman


For Debian or Ubuntu, you can use

$ dpkg --listfiles perl | grep '\.pm$'

For Redhat:

$ rpm -ql perl | grep '\.pm$'
like image 32
Greg Bacon Avatar answered Oct 20 '22 10:10

Greg Bacon