5 corelist - a commandline frontend to Module::CoreList
9 See L<Module::CoreList> for one.
14 corelist [-a|-d] <ModuleName> | /<ModuleRegex>/ [<ModuleVersion>] ...
15 corelist [-v <PerlVersion>] [ <ModuleName> | /<ModuleRegex>/ ] ...
16 corelist [-r <PerlVersion>] ...
17 corelist --utils [-d] <UtilityName> [<UtilityName>] ...
18 corelist --utils -v <PerlVersion>
19 corelist --feature <FeatureName> [<FeatureName>] ...
20 corelist --diff PerlVersion PerlVersion
21 corelist --upstream <ModuleName>
29 lists all versions of the given module (or the matching modules, in case you
30 used a module regexp) in the perls Module::CoreList knows about.
34 Unicode was first released with perl v5.6.2
83 finds the first perl version where a module has been released by
84 date, and not by version number (as is the default).
88 Given two versions of perl, this prints a human-readable table of all module
89 changes between the two. The output format may change in the future, and is
90 meant for I<humans>, not programs. For programs, use the L<Module::CoreList>
95 help! help! help! to see more help, try --man.
103 lists all of the perl release versions we got the CoreList for.
105 If you pass a version argument (value of C<$]>, like C<5.00503> or C<5.008008>),
106 you get a list of all the modules and their respective versions.
107 (If you have the C<version> module, you can also use new-style version numbers,
110 In module filtering context, it can be used as Perl version filter.
114 lists all of the perl releases and when they were released
116 If you pass a perl version you get the release date for that version only.
120 lists the first version of perl each named utility program was released with
122 May be used with -d to modify the first release criteria.
124 If used with -v <version> then all utilities released with that version of perl
125 are listed, and any utility programs named on the command line are ignored.
129 lists the first version bundle of each named feature given
133 Shows if the given module is primarily maintained in perl core or on CPAN
138 As a special case, if you specify the module name C<Unicode>, you'll get
139 the version number of the Unicode Character Database bundled with the
140 requested perl versions.
144 BEGIN { pop @INC if $INC[-1] eq '.' }
145 use Module::CoreList;
146 use Getopt::Long qw(:config no_ignore_case);
150 use List::Util qw/maxstr/;
156 qw[ help|?! man! r|release:s v|version:s a! d diff|D utils feature|f u|upstream ]
159 pod2usage(1) if $Opts{help};
160 pod2usage(-verbose=>2) if $Opts{man};
162 if(exists $Opts{r} ){
164 print "\nModule::CoreList has release info for the following perl versions:\n";
166 my $max_ver_len = max_mod_len(\%Module::CoreList::released);
167 for my $ver ( grep !/0[01]0$/, sort keys %Module::CoreList::released ) {
168 printf "%-${max_ver_len}s %s\n", format_perl_version($ver), $Module::CoreList::released{$ver};
174 my $num_r = numify_version( $Opts{r} );
175 my $version_hash = Module::CoreList->find_version($num_r);
177 if( !$version_hash ) {
178 print "\nModule::CoreList has no info on perl $Opts{r}\n\n";
182 printf "Perl %s was released on %s\n\n", format_perl_version($num_r), $Module::CoreList::released{$num_r};
186 if(exists $Opts{v} ){
188 print "\nModule::CoreList has info on the following perl versions:\n";
189 print format_perl_version($_)."\n" for grep !/0[01]0$/, sort keys %Module::CoreList::version;
194 my $num_v = numify_version( $Opts{v} );
197 utilities_in_version($num_v);
201 my $version_hash = Module::CoreList->find_version($num_v);
203 if( !$version_hash ) {
204 print "\nModule::CoreList has no info on perl $Opts{v}\n\n";
209 print "\nThe following modules were in perl $Opts{v} CORE\n";
210 my $max_mod_len = max_mod_len($version_hash);
211 for my $mod ( sort keys %$version_hash ) {
212 printf "%-${max_mod_len}s %s\n", $mod, $version_hash->{$mod} || "";
221 die "\nprovide exactly two perl core versions to diff with --diff\n";
224 my ($old_ver, $new_ver) = @ARGV;
226 my $old = numify_version($old_ver);
227 if ( !Module::CoreList->find_version($old) ) {
228 print "\nModule::CoreList has no info on perl $old_ver\n\n";
231 my $new = numify_version($new_ver);
232 if ( !Module::CoreList->find_version($new) ) {
233 print "\nModule::CoreList has no info on perl $new_ver\n\n";
237 my %diff = Module::CoreList::changes_between($old, $new);
239 for my $lib (sort keys %diff) {
240 my $diff = $diff{$lib};
242 my $was = ! exists $diff->{left} ? '(absent)'
243 : ! defined $diff->{left} ? '(undef)'
246 my $now = ! exists $diff->{right} ? '(absent)'
247 : ! defined $diff->{right} ? '(undef)'
250 printf "%-35s %10s %10s\n", $lib, $was, $now;
256 die "\n--utils only available with perl v5.19.1 or greater\n"
259 die "\nprovide at least one utility name to --utils\n"
262 warn "\n-a has no effect when --utils is used\n" if $Opts{a};
263 warn "\n--diff has no effect when --utils is used\n" if $Opts{diff};
264 warn "\n--upstream, or -u, has no effect when --utils is used\n" if $Opts{u};
266 my $when = maxstr(values %Module::CoreList::released);
267 print "\n","Data for $when\n";
269 utility_version($_) for @ARGV;
274 if ($Opts{feature}) {
275 die "\n--feature is only available with perl v5.16.0 or greater\n"
278 die "\nprovide at least one feature name to --feature\n"
285 my @bundles = map { $_->[0] }
286 sort { $b->[1] <=> $a->[1] }
287 map { [$_, numify_version($_)] }
288 grep { not /[^0-9.]/ }
289 keys %feature::feature_bundle;
291 for my $version (@bundles) {
292 $feature2version{$_} = $version =~ /^\d\.\d+$/ ? "$version.0" : $version
293 for @{ $feature::feature_bundle{$version} };
296 # allow internal feature names, just in case someone gives us __SUB__
297 # instead of current_sub.
298 while (my ($name, $internal) = each %feature::feature) {
299 $internal =~ s/^feature_//;
300 $feature2version{$internal} = $feature2version{$name}
301 if $feature2version{$name};
304 my $when = maxstr(values %Module::CoreList::released);
305 print "\n","Data for $when\n";
307 for my $feature (@ARGV) {
308 print "feature \"$feature\" ",
309 exists $feature2version{$feature}
310 ? "was first released with the perl "
311 . format_perl_version(numify_version($feature2version{$feature}))
312 . " feature bundle\n"
313 : "doesn't exist (or so I think)\n";
324 if ($ARGV[0] =~ /=/) {
325 ($mod, $ver) = split /=/, shift @ARGV;
328 $ver = (@ARGV && $ARGV[0] =~ /^\d/) ? shift @ARGV : "";
331 if ($mod !~ m|^/(.*)/([imosx]*)$|) { # not a regex
332 module_version($mod,$ver);
335 eval { $re = $2 ? qr/(?$2)($1)/ : qr/$1/; }; # trap exceptions while building regex
337 # regex errors are usually like 'Quantifier follow nothing in regex; marked by ...'
338 # then we drop text after ';' to shorten message
339 my $errmsg = $@ =~ /(.*);/ ? $1 : $@;
340 warn "\n$mod is a bad regex: $errmsg\n";
343 my @mod = Module::CoreList->find_modules($re);
345 module_version($_, $ver) for @mod;
348 print "\n$mod $ver has no match in CORE (or so I think)\n";
360 my $numeric_v = numify_version($Opts{v});
361 my $version_hash = Module::CoreList->find_version($numeric_v);
363 print $mod, " ", $version_hash->{$mod} || 'undef', "\n";
366 else { die "Shouldn't happen" }
370 ? Module::CoreList->first_release_by_date(@_)
371 : Module::CoreList->first_release(@_);
373 $msg .= " $ver" if $ver;
376 ? Module::CoreList->removed_from_by_date($mod)
377 : Module::CoreList->removed_from($mod);
379 my $when = maxstr(values %Module::CoreList::released);
380 print "\n","Data for $when\n";
383 my $deprecated = Module::CoreList->deprecated_in($mod);
385 $msg .= "first " unless $ver;
386 $msg .= "released with perl " . format_perl_version($ret);
387 $msg .= ( $rem ? ',' : ' and' ) . " deprecated (will be CPAN-only) in " . format_perl_version($deprecated) if $deprecated;
388 $msg .= " and removed from " . format_perl_version($rem) if $rem;
390 $msg .= " was not in CORE (or so I think)";
395 if( defined $ret and exists $Opts{u} ) {
396 my $upstream = $Module::CoreList::upstream{$mod};
397 $upstream = 'undef' unless $upstream;
398 print "upstream: $upstream\n";
399 if ( $upstream ne 'blead' ) {
400 my $bugtracker = $Module::CoreList::bug_tracker{$mod};
401 $bugtracker = 'unknown' unless $bugtracker;
402 print "bug tracker: $bugtracker\n";
406 if(defined $ret and exists $Opts{a} and $Opts{a}){
411 sub utility_version {
414 require Module::CoreList::Utils;
416 my $released = $Opts{d}
417 ? Module::CoreList::Utils->first_release_by_date($utility)
418 : Module::CoreList::Utils->first_release($utility);
420 my $removed = $Opts{d}
421 ? Module::CoreList::Utils->removed_from_by_date($utility)
422 : Module::CoreList::Utils->removed_from($utility);
425 print "$utility was first released with perl ", format_perl_version($released);
426 print " and later removed in ", format_perl_version($removed)
430 print "$utility was not in CORE (or so I think)\n";
434 sub utilities_in_version {
437 require Module::CoreList::Utils;
439 my @utilities = Module::CoreList::Utils->utilities($version);
441 if (not @utilities) {
442 print "\nModule::CoreList::Utils has no info on perl $version\n\n";
446 print "\nThe following utilities were in perl ",
447 format_perl_version($version), " CORE\n";
448 print "$_\n" for sort { lc($a) cmp lc($b) } @utilities;
454 my $versions = shift;
456 for my $mod (keys %$versions) {
457 $max = max($max, length $mod);
464 my($this, $that) = @_;
465 return $this if $this > $that;
472 for my $v (grep !/0[01]0$/, sort keys %Module::CoreList::version ) {
473 next unless exists $Module::CoreList::version{$v}{$mod};
475 my $mod_v = $Module::CoreList::version{$v}{$mod} || 'undef';
476 printf " %-10s %-10s\n", format_perl_version($v), $mod_v;
484 sub have_version_pm {
485 return $have_version_pm if defined $have_version_pm;
486 return $have_version_pm = eval { require version; 1 };
491 sub format_perl_version {
493 return $v if $v < 5.006 or !have_version_pm;
494 return version->new($v)->normal;
500 if ($ver =~ /\..+\./) {
502 or die "You need to install version.pm to use dotted version numbers\n";
503 $ver = version->new($ver)->numify;
511 $ corelist File::Spec
513 File::Spec was first released with perl 5.005
515 $ corelist File::Spec 0.83
517 File::Spec 0.83 was released with perl 5.007003
519 $ corelist File::Spec 0.89
521 File::Spec 0.89 was not in CORE (or so I think)
523 $ corelist File::Spec::Aliens
525 File::Spec::Aliens was not in CORE (or so I think)
527 $ corelist /IPC::Open/
529 IPC::Open2 was first released with perl 5
531 IPC::Open3 was first released with perl 5
533 $ corelist /MANIFEST/i
535 ExtUtils::Manifest was first released with perl 5.001
537 $ corelist /Template/
539 /Template/ has no match in CORE (or so I think)
541 $ corelist -v 5.8.8 B
545 $ corelist -v 5.8.8 /^B::/
567 Copyright (c) 2002-2007 by D.H. aka PodMaster
569 Currently maintained by the perl 5 porters E<lt>perl5-porters@perl.orgE<gt>.
571 This program is distributed under the same terms as perl itself.
572 See http://perl.org/ or http://cpan.org/ for more info on that.