This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Attribute-Handlers is of the 0.99 on CPAN
[perl5.git] / Porting / sync-with-cpan
index a0a26d6..d0cc1d6 100755 (executable)
@@ -157,12 +157,20 @@ my @problematic = (
 );
 
 
+sub usage
+{
+    my $err = shift and select STDERR;
+    print "Usage: $0 module [args] [cpan package]\n";
+    exit $err;
+}
+
 GetOptions ('tarball=s'  =>  \my $tarball,
             'version=s'  =>  \my $version,
-             force       =>  \my $force,)
-        or  die "Failed to parse arguments";
+             force       =>  \my $force,
+             help        =>  sub { usage 0; },
+             ) or  die "Failed to parse arguments";
 
-die "Usage: $0 module [args] [cpan package]" unless @ARGV == 1 || @ARGV == 2;
+usage 1 unless @ARGV == 1 || @ARGV == 2;
 
 sub find_type_f {
     my @res;
@@ -218,7 +226,7 @@ chdir "cpan";
 my  $pkg_dir      = $files[0];
     $pkg_dir      =~ s!.*/!!;
 
-my ($old_version) = $distribution =~ /-([0-9.]+)\.tar\.gz/;
+my ($old_version) = $distribution =~ /-([0-9.]+(?:-TRIAL[0-9]*)?)\.tar\.gz/;
 
 my  $o_module     = $module;
 if ($cpan_mod =~ /-/ && $cpan_mod !~ /::/) {
@@ -243,9 +251,9 @@ unless ($tarball) {
         } or system wget => $package_url, '-qO', $package_file;
     }
 
-    my  $new_line = `grep '^$cpan_mod ' $package_file`
+    open my $fh, '<', $package_file;
+    (my $new_line) = grep {/^$cpan_mod/} <$fh> # Yes, this needs a lot of memory
                      or die "Cannot find $cpan_mod on CPAN\n";
-    chomp $new_line;
     (undef, $new_version, my $new_path) = split ' ', $new_line;
     if (defined $version) {
         $new_path =~ s/-$new_version\./-$version\./;
@@ -267,7 +275,7 @@ unless ($tarball) {
 }
 else {
     $new_file     = $tarball;
-    $new_version  = $version // ($new_file =~ /-([0-9._]+)\.tar\.gz/) [0];
+    $new_version  = $version // ($new_file =~ /-([0-9._]+(?:-TRIAL[0-9]*)?)\.tar\.gz/) [0];
 }
 
 my  $old_dir      = "$pkg_dir-$old_version";
@@ -476,7 +484,9 @@ my @tests = glob 'porting/*.t';
 chomp @tests;
 my @failed;
 foreach my $t (@tests) {
-    my @not = `./perl -I../lib -I.. $t | grep ^not | grep -v "# TODO"`;
+    my @not = grep {!/# TODO/ }
+              grep { /^not/ }
+              `${exe_dir}perl -I../lib -I.. $t`;
     print @not ? '!' : '.';
     push @failed => $t if @not;
 }