Using Getopt:Long ...
Is there a way to correctly capture all the files return if the cmd line arg contains a wildcard?
e.g., -f *.dbg ?
Since the shell expands the wildcard prior to perl, double-quoting "*.dbg" will resolves this, but sometimes the users don't always use double-quotes.
I guess I could try looking at the leftover "not matching" values in the @ARGV array after the GetOptions cmd and append those matching files to my original -f array, but that would be an exercise in futility because I wouldn't know what the original user's input file (with wildcard) would of looked like to match on - any thoughts?
my @oCLA;
my @fCLA;
GetOptions("o=i"=>\@oCLA,
"f=s"=>\@fCLA);
print "o: $oCLA\n" if $oCLA[0];
print "o: $oCLA\n" if $oCLA[1];
print "f: $fCLA\n" if $fCLA[0];
foreach (@ARGV) {
print "NOT VALID: $_\n";
}
prompt> zgetargs.pl -o 4 -o 5 -f *.dbg
oCLA: 4
oCLA: 5
fCLA: 2009061119645N01.dbg
NOT VALID: 2009061119645N02.dbg
Is there a way to correctly capture all the files return if the cmd line arg contains a wildcard?
e.g., -f *.dbg ?
Since the shell expands the wildcard prior to perl, double-quoting "*.dbg" will resolves this, but sometimes the users don't always use double-quotes.
I guess I could try looking at the leftover "not matching" values in the @ARGV array after the GetOptions cmd and append those matching files to my original -f array, but that would be an exercise in futility because I wouldn't know what the original user's input file (with wildcard) would of looked like to match on - any thoughts?
my @oCLA;
my @fCLA;
GetOptions("o=i"=>\@oCLA,
"f=s"=>\@fCLA);
print "o: $oCLA\n" if $oCLA[0];
print "o: $oCLA\n" if $oCLA[1];
print "f: $fCLA\n" if $fCLA[0];
foreach (@ARGV) {
print "NOT VALID: $_\n";
}
prompt> zgetargs.pl -o 4 -o 5 -f *.dbg
oCLA: 4
oCLA: 5
fCLA: 2009061119645N01.dbg
NOT VALID: 2009061119645N02.dbg