I would like to get an array of all of the values on the command line that
are not part of options (as GetOpt::Long defines an option.) In
short, GetOpt::Long parses @ARGV pulling out anything that begins with -- as
an option name and the token after it as the argument (with an optional '='
in between them. I want to get an array of the non-option args e.i.:
@ARGV = qw(--x 5 --bar = 6 7 --foo 8 9)
myfunc() = (7, 9);
The example given in GetOpt::Long says to do the following:
my $width = 80;
sub process { ... }
GetOptions ('width=i' => \$width, '<>' => \&process);
which invokes &process with every argument allowing me to push on to some
global array within the procedure. However, for some reason which I cannot
understand, this method requires that you have at least one named option in
the call to GetOptions because the following program:
sub process { ... }
GetOptions ('<>' => \&process);
produces the following error:
Error in option spec: "CODE(0x80e4bbc)"
Does anyone know how I can pull out the non-option arguments without needing
to have some named option present.
Thanks a lot,
-mike
p.s. In case anyone's wondering why I just use @ARGV itself since I
apparently don't have any named options, I do in fact have named options. I
just don't know their names ahead of time.
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm