且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何知道最初在机器上安装特定Perl的模块?

更新时间:2022-03-30 23:19:54

一般来说,你不能。如果您接受并从不同的角度来解决问题,那么您的沮丧就会减少很多。 Module :: CoreList 提供了应该的列表在所有安装中都包含在最低限度内,但是供应商不需要遵守,大多数发行版包括许多不是核心部分的模块。禁止建立自己的数据库,其中包含哪个版本的每个发行版 - 一项艰巨的任务 - 没有太多希望。请注意,即使对于发行版本的模块,安装的版本可能会有所不同。

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. 如果您在开发阶段知道您的目标(例如,特定的
    版本的ActivePerl),您可以根据这些决定。

  2. 对于一般情况,将应用程序部署为模块并指定
    依赖关系。例如使用 Module :: Build ,并在
    需要Build.pl脚本的部分。 cpan shell可以自动跟踪并解决
    依赖关系。

  3. 如果您想要回避问题,请使用 PAR Par :: Packer
    创建自包含的部署包。

  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.