From: Rafael Garcia-Suarez Date: Tue, 6 Jun 2006 16:30:36 +0000 (+0000) Subject: Upgrade to Module::CoreList 2.05 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=18b19aecdfa8e9a21e5eca3a11e12fc13e8e219b;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Module::CoreList 2.05 (contains a patch by Adriano Ferreira to make corelist accept regexps as arguments) p4raw-id: //depot/perl@28360 --- diff --git a/MANIFEST b/MANIFEST index c4d05eb..96faac6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2030,6 +2030,7 @@ lib/Module/Build/YAML.pm Module::Build lib/Module/CoreList/bin/corelist Module::CoreList lib/Module/CoreList.pm Module::CoreList lib/Module/CoreList/t/corelist.t Module::CoreList +lib/Module/CoreList/t/find_modules.t Module::CoreList lib/Net/Changes.libnet libnet lib/Net/Cmd.pm libnet lib/Net/Config.eg libnet diff --git a/lib/Module/CoreList.pm b/lib/Module/CoreList.pm index e3ae795..c14a0de 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.04'; +$VERSION = '2.05'; =head1 NAME @@ -16,6 +16,11 @@ Module::CoreList - what modules shipped with versions of perl print Module::CoreList->first_release('File::Spec'); # prints 5.00503 print Module::CoreList->first_release('File::Spec', 0.82); # prints 5.006001 + print join ', ', Module::CoreList->find_modules(qr/Data/); + # prints 'Data::Dumper' + print join ', ', Module::CoreList->find_modules(qr/test::h.*::.*s/i, 5.008008); + # prints 'Test::Harness::Assert, Test::Harness::Straps' + print join ", ", @{ $Module::CoreList::families{5.005} }; # prints "5.005, 5.00503, 5.00504" @@ -99,6 +104,21 @@ sub first_release { return (sort { $released{$a} cmp $released{$b} } @perls)[0]; } +sub find_modules { + my $discard = shift; + my $regex = shift; + my @perls = @_; + @perls = keys %version unless @perls; + + my %mods; + foreach (@perls) { + while (my ($k, $v) = each %{$version{$_}}) { + $mods{$k}++ if $k =~ $regex; + } + } + return sort keys %mods +} + # when things escaped %released = ( diff --git a/lib/Module/CoreList/bin/corelist b/lib/Module/CoreList/bin/corelist index f565da0..15af4a6 100644 --- a/lib/Module/CoreList/bin/corelist +++ b/lib/Module/CoreList/bin/corelist @@ -10,7 +10,7 @@ See L for one. =head1 SYNOPSIS - corelist [-a] [ Modulename [ version ]] ... + corelist [-a] [ Modulename [ version ]] [ /Modulenameregex/ [ version ] ] ... corelist [-v [ version ]] =head1 OPTIONS @@ -96,7 +96,29 @@ if(exists $Opts{v} ){ $mod = shift @ARGV; $ver = (@ARGV && $ARGV[0] =~ /^\d/) ? shift @ARGV : ""; } - module_version($mod,$ver); + + if ($mod !~ m|^/(.*)/([imosx]*)$|) { # not a regex + module_version($mod,$ver); + } else { + my $re; + eval { $re = $2 ? qr/(?$2)($1)/ : qr/$1/; }; # trap exceptions while building regex + if ($@) { + # regex errors are usually like 'Quantifier follow nothing in regex; marked by ...' + # then we drop text after ';' to shorten message + my $errmsg = $@ =~ /(.*);/ ? $1 : $@; + warn "\n$mod is a bad regex: $errmsg\n"; + next; + } + my @mod = Module::CoreList->find_modules($re); + if (@mod) { + module_version($_, $ver) for @mod; + } else { + $ver |= ''; + print "\n$mod $ver has no match in CORE (or so I think)\n"; + } + + } + } } else { pod2usage(0); @@ -155,6 +177,21 @@ sub module_version { File::Spec::Aliens was not in CORE (or so I think) + $ corelist /IPC::Open/ + + IPC::Open2 was first released with perl 5 + + IPC::Open3 was first released with perl 5 + + $ corelist /MANIFEST/i + + ExtUtils::Manifest was first released with perl 5.001 + + $ corelist /Template/ + + /Template/ has no match in CORE (or so I think) + + =head1 COPYRIGHT Copyright (c) 2002-2006 by D.H. aka PodMaster diff --git a/lib/Module/CoreList/t/find_modules.t b/lib/Module/CoreList/t/find_modules.t new file mode 100644 index 0000000..243e0dc --- /dev/null +++ b/lib/Module/CoreList/t/find_modules.t @@ -0,0 +1,20 @@ +#!perl -w +use strict; +use Module::CoreList; +use Test::More tests => 5; + +BEGIN { require_ok('Module::CoreList'); } + +is_deeply([ Module::CoreList->find_modules(qr/warnings/) ], + [ qw(encoding::warnings warnings warnings::register) ], + 'qr/warnings/'); + +is_deeply([ Module::CoreList->find_modules(qr/IPC::Open/) ], + [ qw(IPC::Open2 IPC::Open3) ], + 'qr/IPC::Open/'); + +is_deeply([ Module::CoreList->find_modules(qr/Module::/, 5.008008) ], [], 'qr/Module::/ at 5.008008'); + +is_deeply([ Module::CoreList->find_modules(qr/Test::H.*::.*s/, 5.006001, 5.007003) ], + [ qw(Test::Harness::Assert Test::Harness::Straps) ], + 'qr/Test::H.*::.*s/ at 5.006001 and 5.007003');