=head1 SYNOPSIS
corelist -v
- corelist [-a] <ModuleName> | /<ModuleRegex>/ [<ModuleVersion>] ...
+ corelist [-a|-d] <ModuleName> | /<ModuleRegex>/ [<ModuleVersion>] ...
corelist [-v <PerlVersion>] [ <ModuleName> | /<ModuleRegex>/ ] ...
=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.
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.
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};
}
$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;
}
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;
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;
}