I've been playing with the Perl AppConfig module (http://search.cpan.org/~abw/AppConfig-1.66/lib/AppConfig.pm)
It seems that the getopt() method messes up the global @ARGV array even if I pass it a copy.
For example:
#!/usr/bin/perl
use strict;
use warnings;
use AppConfig;
my $opts = AppConfig->new( { CASE => 0, } );
$opts->define('config=s', {DEFAULT => ''});
print "ARGV: @ARGVn";
my $argvCopy = [@ARGV];
print "argvCopy: @$argvCopyn";
$opts->args($argvCopy);
print "after args() ARGV: @ARGVn";
$opts->getopt(qw(auto_abbrev), $argvCopy);
print "after getopt() ARGV: @ARGVn";
produces this output
# appconfig-error.pl --config xyz 123 abc
ARGV: --config xyz 123 abc
argvCopy: --config xyz 123 abc
after args() ARGV: --config xyz 123 abc # @ARGV is still complete
after getopt() ARGV: 123 abc # @ARGV has bits missing
This is a problem because I need to call getopt() twice — once to get at the –config option, then I read the configuration file with the file() method, then I re-read the command line options so that they override the ones in the configuration file.
Using args() is OK — @ARGV is preserved — but I need the extra feature of getopt().
I've emailed the author, so I'll wait to see what his reply is.