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 d436703..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.]+(?:-TRIAL)?)\.tar\.gz/;
+my ($old_version) = $distribution =~ /-([0-9.]+(?:-TRIAL[0-9]*)?)\.tar\.gz/;
 
 my  $o_module     = $module;
 if ($cpan_mod =~ /-/ && $cpan_mod !~ /::/) {
@@ -267,7 +275,7 @@ unless ($tarball) {
 }
 else {
     $new_file     = $tarball;
-    $new_version  = $version // ($new_file =~ /-([0-9._]+(?:-TRIAL)?)\.tar\.gz/) [0];
+    $new_version  = $version // ($new_file =~ /-([0-9._]+(?:-TRIAL[0-9]*)?)\.tar\.gz/) [0];
 }
 
 my  $old_dir      = "$pkg_dir-$old_version";