Porting/corelist-perldelta.pl - Default to comparing last two versions
authorAbir Viqar <abiviq@hushmail.com>
Sat, 14 Dec 2013 19:03:59 +0000 (14:03 -0500)
committerSteve Hay <steve.m.hay@googlemail.com>
Thu, 19 Dec 2013 17:26:25 +0000 (17:26 +0000)
do_update_existing() previously required versions to be specified

Porting/corelist-perldelta.pl

index a91d27e..0a9695e 100755 (executable)
@@ -57,9 +57,18 @@ sub run {
 
   # by default, compare latest two version in CoreList;
   my @versions = sort keys %Module::CoreList::version;
-  my ($old, $new) = (shift @ARGV, shift @ARGV);
-  $old ||= $versions[-2];
-  $new ||= $versions[-1];
+  my $old = $versions[-2];
+  my $new = $versions[-1];
+
+  # use the provided versions if present
+  # @ARGV >=2 means [old_version] [new_version] [path/to/file]
+  if ( @ARGV >= 2) {
+    ($old, $new) = (shift @ARGV, shift @ARGV);
+    die "$old is an invalid version\n" if not exists
+      $Module::CoreList::version{$old};
+    die "$new is an invalid verison\n" if not exists
+      $Module::CoreList::version{$new};
+  }
 
   if ( $opt{mode} eq 'generate' ) {
     do_generate($old => $new);