7

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.

4

3 回答 3

6

一般来说你不能。如果您接受这一点并从不同的角度解决问题,您的挫败感就会少得多。Module::CoreList提供了所有安装中包含的最低限度的列表,但供应商不需要遵守该列表,并且大多数发行版包含许多不属于核心的模块。除非为每个发行版的哪个版本中包含的内容建立自己的数据库——这是一项艰巨的任务——否则希望不大。请注意,即使对于发行版附带的模块,安装的版本也可能不同。

我可以看到几种不同的方法来解决这个问题:

  1. 如果您在开发时知道您的目标(例如 ActivePerl 的特定版本),您可以根据它做出决定。
  2. 对于一般情况,像模块一样部署您的应用程序并指定依赖项。例如,使用Module::Buildrequires并在 Build.pl 脚本部分列出先决条件 。cpan shell 可以自动跟踪和解决依赖关系。
  3. 如果您想完全回避这个问题,请使用PARPar::Packer创建自包含的部署包。
于 2010-01-18T16:49:37.343 回答
6

对于 Debian 或 Ubuntu,您可以使用

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

对于红帽:

$ rpm -ql perl | grep '\.pm$'
于 2010-01-18T16:27:55.393 回答
0

我正在寻找最初安装的内容,作为该安装的一部分提供的模块,内置的。不是从那以后安装的。

也许对于非核心模块,您可以解析 perllocal.pod,将与 Perl 安装本身一起安装的初始批次模块与基于日期的后续模块分开。您正在寻找以下行:

=head2 Wed Apr 30 15:40:38 2008: C<Module> L<URI|URI>

所以前几个大概是那些用 Perl 本身安装的并且应该有相同的日期(尽管当然不是相同的时间)。那些以 24 小时或更长时间安装的将是您正在寻找的。

不确定核心模块,因为我认为您在链接到的上一个问题中得到的答案是令人满意的,但显然您不这么认为。可能我错过了一些东西:)

干杯,提供

于 2010-01-18T14:12:16.720 回答