summaryrefslogtreecommitdiff
path: root/lib/Module
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-06-06 16:30:36 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-06-06 16:30:36 +0000
commit18b19aecdfa8e9a21e5eca3a11e12fc13e8e219b (patch)
treee8352e54fa2a88a3f4ea81526044ac6969c1e25c /lib/Module
parent656ebd29b326e7cb4e9181b77b10fccb1c1df3c6 (diff)
downloadperl-18b19aecdfa8e9a21e5eca3a11e12fc13e8e219b.tar.gz
Upgrade to Module::CoreList 2.05
(contains a patch by Adriano Ferreira to make corelist accept regexps as arguments) p4raw-id: //depot/perl@28360
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/CoreList.pm22
-rw-r--r--lib/Module/CoreList/bin/corelist41
-rw-r--r--lib/Module/CoreList/t/find_modules.t20
3 files changed, 80 insertions, 3 deletions
diff --git a/lib/Module/CoreList.pm b/lib/Module/CoreList.pm
index e3ae79549e..c14a0dee60 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 f565da0e0b..15af4a657e 100644
--- a/lib/Module/CoreList/bin/corelist
+++ b/lib/Module/CoreList/bin/corelist
@@ -10,7 +10,7 @@ See L<Module::CoreList> 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 0000000000..243e0dcdda
--- /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');