summaryrefslogtreecommitdiff
path: root/lib/Module
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-05-10 10:18:32 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-05-10 10:18:32 +0000
commit79be940f0d1103e090718837115e35edaebee088 (patch)
tree2f1bee2b48d688dad7d8a12a1e0db58ac3916dd7 /lib/Module
parent48441d71a001d55993adc5d7cf3c122d8b13b721 (diff)
downloadperl-79be940f0d1103e090718837115e35edaebee088.tar.gz
first_release() now returns the first release in the order of
perl version numbers. Add a new method first_release_by_date() to keep the old behaviour available. Suggested by Michael G Schwern. p4raw-id: //depot/perl@31192
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/CoreList.pm28
-rw-r--r--lib/Module/CoreList/t/corelist.t7
2 files changed, 27 insertions, 8 deletions
diff --git a/lib/Module/CoreList.pm b/lib/Module/CoreList.pm
index 709fadaade..14c98a7943 100644
--- a/lib/Module/CoreList.pm
+++ b/lib/Module/CoreList.pm
@@ -1,7 +1,7 @@
package Module::CoreList;
use strict;
use vars qw/$VERSION %released %patchlevel %version %families/;
-$VERSION = '2.10';
+$VERSION = '2.11';
=head1 NAME
@@ -13,8 +13,9 @@ Module::CoreList - what modules shipped with versions of perl
print $Module::CoreList::version{5.00503}{CPAN}; # prints 1.48
- print Module::CoreList->first_release('File::Spec'); # prints 5.00503
- print Module::CoreList->first_release('File::Spec', 0.82); # prints 5.006001
+ print Module::CoreList->first_release('File::Spec'); # prints 5.00405
+ print Module::CoreList->first_release_by_date('File::Spec'); # prints 5.005
+ print Module::CoreList->first_release('File::Spec', 0.82); # prints 5.006001
print join ', ', Module::CoreList->find_modules(qr/Data/);
# prints 'Data::Dumper'
@@ -47,8 +48,12 @@ In 2.01 %Module::CoreList::patchlevel contains the branch and patchlevel
corresponding to the specified perl version in the Perforce repository where
the perl sources are kept.
-The special module name C<Unicode> refers to the version of the Unicode
-Character Database bundled with Perl.
+Starting with 2.10, the special module name C<Unicode> refers to the version of
+the Unicode Character Database bundled with Perl.
+
+Since 2.11, Module::CoreList::first_release() returns the first release
+in the order of perl version numbers. If you want to get the earliest
+perl release instead, use Module::CoreList::first_release_by_date().
=head1 CAVEATS
@@ -95,7 +100,7 @@ END {
}
-sub first_release {
+sub first_release_raw {
my ($discard, $module, $version) = @_;
my @perls = $version
@@ -103,10 +108,21 @@ sub first_release {
$version{$_}{ $module } ge $version } keys %version
: grep { exists $version{$_}{ $module } } keys %version;
+ return @perls;
+}
+
+sub first_release_by_date {
+ my @perls = &first_release_raw;
return unless @perls;
return (sort { $released{$a} cmp $released{$b} } @perls)[0];
}
+sub first_release {
+ my @perls = &first_release_raw;
+ return unless @perls;
+ return (sort { $a cmp $b } @perls)[0];
+}
+
sub find_modules {
my $discard = shift;
my $regex = shift;
diff --git a/lib/Module/CoreList/t/corelist.t b/lib/Module/CoreList/t/corelist.t
index 9f84ee3c72..a79e58c1d3 100644
--- a/lib/Module/CoreList/t/corelist.t
+++ b/lib/Module/CoreList/t/corelist.t
@@ -1,7 +1,7 @@
#!perl -w
use strict;
use Module::CoreList;
-use Test::More tests => 12;
+use Test::More tests => 13;
BEGIN { require_ok('Module::CoreList'); }
@@ -20,9 +20,12 @@ ok($Module::CoreList::version{5.007003}, "5.007003");
ok(exists $Module::CoreList::version{5.007003}{'Attribute::Handlers'},
"Attribute::Handlers were bundled with 5.7.3");
-is(Module::CoreList->first_release('File::Spec'), 5.005,
+is(Module::CoreList->first_release_by_date('File::Spec'), 5.005,
"File::Spec was first bundled in 5.005");
+is(Module::CoreList->first_release('File::Spec'), 5.00405,
+ "File::Spec was released in perl with lowest version number 5.00405");
+
is(Module::CoreList->first_release('File::Spec', 0.82), 5.006_001,
"File::Spec reached 0.82 with 5.006_001");