From: Rafael Garcia-Suarez Date: Thu, 7 Feb 2008 09:40:12 +0000 (+0000) Subject: corelist changes: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6127f3cdd06593c6b2ae0fd71ffeb484fc61cc31;p=p5sagit%2Fp5-mst-13.2.git corelist changes: - Add a new -d option to find first perl version by date and not by version number - Better handling of perl versions that end with a 0 - use version.pm only for version numbers that have multiple dots p4raw-id: //depot/perl@33244 --- diff --git a/lib/Module/CoreList.pm b/lib/Module/CoreList.pm index 26bf381..e032a93 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.13'; +$VERSION = '2.14'; =head1 NAME @@ -138,6 +138,11 @@ sub find_modules { return sort keys %mods } +sub find_version { + my ($class, $v) = @_; + return $version{$v} if defined $version{$v}; + return undef; +} # when things escaped %released = ( diff --git a/lib/Module/CoreList/bin/corelist b/lib/Module/CoreList/bin/corelist index 005e582..b59aef3 100644 --- a/lib/Module/CoreList/bin/corelist +++ b/lib/Module/CoreList/bin/corelist @@ -11,14 +11,14 @@ See L for one. =head1 SYNOPSIS corelist -v - corelist [-a] | // [] ... + corelist [-a|-d] | // [] ... corelist [-v ] [ | // ] ... =head1 OPTIONS =over -=item -a modulename +=item -a lists all versions of the given module (or the matching modules, in case you used a module regexp) in the perls Module::CoreList knows about. @@ -44,6 +44,11 @@ used a module regexp) in the perls Module::CoreList knows about. 5.009002 1.04 5.009003 1.06 +=item -d + +finds the first perl version where a module has been released by +date, and not by version number (as is the default). + =item -? or -help help! help! help! to see more help, try --man. @@ -79,7 +84,7 @@ use warnings; my %Opts; -GetOptions(\%Opts, qw[ help|?! man! v|version:f a! ] ); +GetOptions(\%Opts, qw[ help|?! man! v|version:f a! d ] ); pod2usage(1) if $Opts{help}; pod2usage(-verbose=>2) if $Opts{man}; @@ -93,15 +98,16 @@ if(exists $Opts{v} ){ } $Opts{v} = numify_version( $Opts{v} ); - if( !exists $Module::CoreList::version{$Opts{v}} ) { + my $version_hash = Module::CoreList->find_version($Opts{v}); + if( !$version_hash ) { print "\nModule::CoreList has no info on perl v$Opts{v}\n\n"; exit 1; } if ( !@ARGV ) { print "\nThe following modules were in perl v$Opts{v} CORE\n"; - print "$_ ", $Module::CoreList::version{$Opts{v}}{$_} || " ","\n" - for sort keys %{$Module::CoreList::version{$Opts{v}}}; + print "$_ ", $version_hash->{$_} || " ","\n" + for sort keys %$version_hash; print "\n"; exit 0; } @@ -149,12 +155,17 @@ sub module_version { my($mod,$ver) = @_; if ( $Opts{v} ) { - return printf " %-24s %-10s\n", - $mod, - $Module::CoreList::version{$Opts{v}}{$mod} || 'undef'; + my $version_hash = Module::CoreList->find_version($Opts{v}); + if ($version_hash) { + print $mod, " ", $version_hash->{$mod} || 'undef', "\n"; + return; + } + else { die "Shouldn't happen" } } - my $ret = Module::CoreList->first_release(@_); + my $ret = $Opts{d} + ? Module::CoreList->first_release_by_date(@_) + : Module::CoreList->first_release(@_); my $msg = $mod; $msg .= " $ver" if $ver; @@ -184,13 +195,12 @@ sub module_version { sub numify_version { my $ver = shift; - if ( index( $ver, q{.}, index( $ver, q{.} ) ) >= 0 ) { - eval { require version }; - if ($@) { - die "You need to install version.pm to use dotted version numbers\n"; - } + if ($ver =~ /\..+\./) { + eval { require version ; 1 } + or die "You need to install version.pm to use dotted version numbers\n"; $ver = version->new($ver)->numify; } + $ver += 0; return $ver; }