update Porting/corecpan.pl to handle new ext/ structure better
authorDavid Mitchell <davem@iabyn.com>
Sun, 17 May 2009 00:31:56 +0000 (01:31 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 20 May 2009 20:43:05 +0000 (21:43 +0100)
(better filename -> module name conversion results in less failed
CPAN version lookups)

(cherry picked from commit f6e59a58ce5f29ee30bbfb2cb10fc14905407320)

Porting/corecpan.pl

index d035bcd..f57899f 100644 (file)
@@ -89,11 +89,13 @@ foreach my $source (@sources) {
            # some heuristics to figure out the module name from the file name
            $module =~ s{^(lib|ext)/}{}
                and $1 eq 'ext'
-               and ( $module =~ s{^(.*)/lib/\1\b}{$1},
-                     $module =~ s{(\w+)/\1\b}{$1},
-                     $module =~ s{^Encode/encoding}{encoding},
-                     $module =~ s{^MIME/Base64/QuotedPrint}{MIME/QuotedPrint},
-                     $module =~ s{^List/Util/lib/Scalar}{Scalar},
+               and (
+                     # ext/Foo-Bar/Bar.pm
+                     $module =~ s{^(\w+)-(\w+)/\2$}{$1/lib/$1/$2},
+                     # ext/Encode/Foo/Foo.pm
+                     $module =~ s{^(Encode)/(\w+)/\2$}{$1/lib/$1/$2},
+                     $module =~ s{^[^/]+/}{},
+                     $module =~ s{^lib/}{},
                    );
            $module =~ s{/}{::}g;
            my $vcpan = $cpanversions{$module} // 'undef';