From: Rafael Garcia-Suarez Date: Thu, 10 May 2007 10:18:32 +0000 (+0000) Subject: first_release() now returns the first release in the order of X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=79be940f0d1103e090718837115e35edaebee088;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/lib/Module/CoreList.pm b/lib/Module/CoreList.pm index 709fada..14c98a7 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 refers to the version of the Unicode -Character Database bundled with Perl. +Starting with 2.10, the special module name C 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 9f84ee3..a79e58c 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");