Mark Overmeer wrote:
> Hi,
> 
> Using Makefile.PL, I often feel a need to enforce the upgrade for
> an optional module, but only when that module is already installed.
> 
> I have many modules which more or less depend on each other.  Sometimes,
> my modules get interface improvements which are usable by other optionally
> installed related modules.  I would like to be able to trigger an upgrade
> of these optional modules, only when they are installed.
> 
> So, besides enforcing an upgrade to a minimal version
>    PREREQ_PM => { XML::Compile::Tester => '0.05'}
> 
> an upgrade-if-installed to a minimal version
>    UPGRADE_PM => { XML::Compile::Cache => '0.90' }
> 
> Or is there an other nice generic way to achieve this?

Simplest thing to do is this.

my $module_is_installed = eval { require Some::Module };
$upgrade_prereqs{"Some::Module"} = 0.05 if eval { require Some::Module };

PREREQ_PM => {
    %upgrade_prereqs,
    ...regular prereqs...
}

Just watch out because the state of your current system will be recorded in
the META.yml.  So you'll want to write out "requires" manually, excluding your
optional modules, and put them instead in "recommends".  Use the new META_ADD
for that.


-- 
Stabbing you in the face so you don't have to.

Reply via email to