I'm not sure if I get the intent of your example... Did you mean to say you wanted a command line syntax like this:
makeupscript.pl -c *.txt -o outputfile.txt -l asdf.pl
In order for that to work, you have two options:
(1) You could put appropriate quotation marks around the '*.txt' (or "escape" the "*"), so that the shell will treat it as a literal string and pass it directly to the script, rather than trying to expand it to the set of matching file names. (In unix shells, you escape a chosen character by putting backslash in front of it: \*.txt). This way, you have to do a "glob" inside the script to get the set of matching file names.
(2) You could restructure the syntax, to something like this:
makeupscript.pl -o outputfile.txt -l asdf.pl *.txt
Note that this does not use "-c" to identify the "role" of the "*.txt" arg(s) -- "-o" still assigns a role to "outputfile.txt" and "-l" still identifies "asdf.pl" -- and by using either Getopt::Std or Getopt::Long, the relative ordering of these two options doesn't matter (update, to clarify, "-o arg" can preced or follow "-l arg") -- but all other arguments on the command line are assumed to be the list of *.txt files (update, to clarify: both "-o arg" and "-l arg" must precede all such args). The shell expands "*.txt" to the set of matching file names, and they all go into @ARGV (update: and are still in @ARGV after the Getopt work is done).
(Note that some (most?) shells have a limit on the amount of memory available for argument expansions on a command line. If there are many hundreds or thousands of files that would match, you might not be able to run the command this way.) |