In a Perl distribution, what would be the recommended way to specify a "dependency" type that says: update these modules to at least these versions, if you have them installed?
I would do something like (untested):
In the Makefile.PL, list all dependencies along with their minimum required versions:
...
my %min_version = (Some/Place/Foo.pm => 0.06, # need at least version
+0.06 of Some::Place::Foo
Other/Spot/Bar.pm => 1.35, # need at least version
+1.35 of Other::Spot::Bar
Baz.pm => 2.72, # need at least version
+2.72 of Baz
);
my @prereqs;
for(keys(%min_version)) {
eval {require $_};
# Ignore modules that don't load.
unless($@){
my $m = $_;
$m =~ s/\//::/g;
$m =~ s/\.pm$//;
my $v = $min_version{$_};
push @prereqs($m, $v);
}
}
my %h = @prereqs;
....
And then, in WriteMakefile() section of the Makefile.PL, I would specify:
...
'PREREQ_PM' => \%h,
...
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.