manually push option arguments to array instead of using s@
By mixing s@ for --$foo-hook options and manual pushing in --hook-dir, it can happen that options get lost. Consider the following test: use Getopt::Long; my $arr = []; GetOptions( 'A=s@' => \$arr, 'B=s' => sub { push @{$arr}, $_[1]; } ); foreach my $hook (@{$arr}) { print "hook: $hook\n"; } This works fine: perl test.pl --A=a1 --B=b1 --A=a2 --B=b2 hook: a1 hook: b1 hook: a2 hook: b2 This misses b1: perl test.pl --B=b1 --A=a2 --B=b2 hook: a2 hook: b2pull/24/head
parent
26af846d0a
commit
0664792cd5
Loading…
Reference in New Issue