0

我想在一个地方为几个项目设置相同的版本。我试过了:

use ExtUtils::MakeMaker;

WriteMakefile(
    VERSION_FROM => 'lib/project/version.pm',
    ...

在“lib/project/version.pm”中:

package project::version;
use AnotherProject;
our $VERSION = AnotherProject->VERSION();
1;

注意:AnotherProject 位于单独的目录中,但可以通过“使用 AnotherProject”加载。并包含'我们的 $VERSION="1.00" '。

$ perl Makefile.PL
WARNING: Setting VERSION via file 'lib/project/version.pm' failed
 at /usr/lib64/perl5/5.18.2/ExtUtils/MakeMaker.pm line 599.
Can't parse version 'undef'

是否可以从另一个模块传递(获取)版本字符串?

也许还有其他方法可以做到这一点,请支持我。

4

1 回答 1

1

When you use VERSION_FROM, ExtUtils::MakeMaker doesn't run the file you point at, it parses it itself and tries to find a version number that way. In this case, that won't work. Using VERSION instead of VERSION_FROM in Makefile.PL and calling the other module from there should work.

于 2014-08-22T09:39:43.453 回答