bug-parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can't run w Getopt::Long v2.35 (perl 5.8.8)


From: Andreas Bernauer
Subject: Can't run w Getopt::Long v2.35 (perl 5.8.8)
Date: Mon, 15 Nov 2010 09:42:37 +0100
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

Hi,

I get a run-time error with the new parallel (v20101113):

$ parallel --version
"GetOptionsFromArray" is not exported by the Getopt::Long module
Can't continue after import errors at /home/bernauer/.root/bin/parallel
line 2422
BEGIN failed--compilation aborted at /home/bernauer/.root/bin/parallel
line 2422.

$ perl --version
This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
$ perl -MGetopt::Long -e 'print $Getopt::Long::VERSION, "\n"'
2.35

I'm running Ubuntu 8.04.4 LTS.

Actually, there is no GetOptionsFromArray in Getopt::Long; this seems to
have been introduced between version 2.35 and 2.38 of Getopt::Long.
Updating Getopt::Long to version 2.38 fixes the problem.

Alternatively, the following patch makes parallel work with Getopt::Long
version 2.35 (again). It uses GetOptions instead of the new
GetOptionsFromArray. To do so, it emulates the behavior of
GetOptionsFromArray, including changing @ARGV only if it was given as an
argument. A quick test run returned the same results, but I did not test
it extensively (I could not find a test suite).

===== 8< snip =============
--- parallel.old        2010-11-15 09:28:23.000000000 +0100
+++ parallel    2010-11-15 09:29:19.000000000 +0100
@@ -2419,7 +2419,7 @@
 use IO::File;
 use POSIX qw(:sys_wait_h setsid);
 use File::Temp qw(tempfile tempdir);
-use Getopt::Long qw(GetOptionsFromArray);
+use Getopt::Long qw(GetOptions);
 use strict;
 
 do_not_reap();
@@ -2475,8 +2475,10 @@
     #   false if parsing failed
     #   @array is changed
     my $array_ref = shift;
-    return GetOptionsFromArray
-       ($array_ref,
+       my $restore_argv = ($array_ref != address@hidden);
+       my @old_argv = @ARGV;
+       @ARGV = @$array_ref;
+       my $res = GetOptions(
         "debug|D" => \$::opt_D,
         "xargs|m" => \$::opt_m,
         "X" => \$::opt_X,
@@ -2544,6 +2546,11 @@
         "Y|shebang|hashbang" => \$::opt_shebang,
         "skip-first-line" => \$::opt_skip_first_line,
        );
+       @$array_ref = @ARGV;
+       if ($restore_argv) {
+               @ARGV = @old_argv;
+       }
+       return $res;
 }
 
 sub parse_options {
==== >8 snap =========


Cheers,

Andreas.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]