in reply to Getopt Long and processing arrays from Linux shell
How about taking advantage of :
"Options can take multiple values at once, for example...
This can be accomplished by adding a repeat specifier to the option specification.
Repeat specifiers are very similar to the {...} repeat specifiers that can be used with regular expression patterns
....
It is also possible to specify the minimal and maximal number of arguments an option takes.
foo=s{2,4} indicates an option that takes at least two and at most 4 arguments.
foo=s{,} indicates one or more values; foo:s{,} indicates zero or more option values."
#!/usr/bin/perl use strict; use warnings; use Getopt::Long qw (GetOptions); my (@Files); Getopt::Long::Configure("no_ignore_case", "prefix_pattern=(--|-|\/)"); GetOptions ("file=s{,}" => \@Files); foreach (@Files) { #Do stuff with file print "$_\n"; }
|
|---|