From 835bc8415256d8a5554afdff2ddf0f7291ac41a3 Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Tue, 1 May 2012 18:28:43 -0400 Subject: [PATCH] add the --diff option to corelist --- dist/Module-CoreList/Changes | 3 +++ dist/Module-CoreList/corelist | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/dist/Module-CoreList/Changes b/dist/Module-CoreList/Changes index c0c932b..a0ec032 100644 --- a/dist/Module-CoreList/Changes +++ b/dist/Module-CoreList/Changes @@ -1,3 +1,6 @@ +2.66 ?? + - Add the --diff option to compare two perl core modlibs + 2.65 Tue Mar 20 2012 - Update of lib/charnames diff --git a/dist/Module-CoreList/corelist b/dist/Module-CoreList/corelist index d5dac05..adf0fb0 100644 --- a/dist/Module-CoreList/corelist +++ b/dist/Module-CoreList/corelist @@ -14,6 +14,7 @@ See L for one. corelist [-a|-d] | // [] ... corelist [-v ] [ | // ] ... corelist [-r ] ... + corelist --diff PerlVersion PerlVersion =head1 OPTIONS @@ -78,6 +79,13 @@ used a module regexp) in the perls Module::CoreList knows about. finds the first perl version where a module has been released by date, and not by version number (as is the default). +=item --diff + +Given two versions of perl, this prints a human-readable table of all module +changes between the two. The output format may change in the future, and is +meant for I, not programs. For programs, use the L +API. + =item -? or -help help! help! help! to see more help, try --man. @@ -119,7 +127,10 @@ use warnings; my %Opts; -GetOptions(\%Opts, qw[ help|?! man! r|release:s v|version:s a! d ] ); +GetOptions( + \%Opts, + qw[ help|?! man! r|release:s v|version:s a! d diff|D ] +); pod2usage(1) if $Opts{help}; pod2usage(-verbose=>2) if $Opts{man}; @@ -175,6 +186,32 @@ if(exists $Opts{v} ){ } } +if ($Opts{diff}) { + if(@ARGV != 2) { + die "\nprovide exactly two perl core versions to diff with --diff\n"; + } + + my ($old_ver, $new_ver) = @ARGV; + + my $old = $Module::CoreList::version{ numify_version($old_ver) }; + my $new = $Module::CoreList::version{ numify_version($new_ver) }; + + my %uniq = (%$old, %$new); + for my $lib (sort keys %uniq) { + my $old = exists $old->{ $lib } + ? (defined $old->{ $lib } ? $old->{ $lib } : '(undef)') + : '(absent)'; + my $new = exists $new->{ $lib } + ? (defined $new->{ $lib } ? $new->{ $lib } : '(undef)') + : '(absent)'; + + next if $old eq $new; + + printf "%-35s %10s %10s\n", $lib, $old, $new; + } + exit(0); +} + if ( !@ARGV ) { pod2usage(0); } -- 2.7.4