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
package Module::CoreList;
use strict;
use vars qw/$VERSION %released %patchlevel %version %families/;
-$VERSION = '2.04';
+$VERSION = '2.05';
=head1 NAME
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"
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 = (
=head1 SYNOPSIS
- corelist [-a] [ Modulename [ version ]] ...
+ corelist [-a] [ Modulename [ version ]] [ /Modulenameregex/ [ version ] ] ...
corelist [-v [ version ]]
=head1 OPTIONS
$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);
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
--- /dev/null
+#!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');