Perl Programming Page 7 - Processing Command Line Options with PERL |
Getopt::Long.pm can also process command-line arguments containing multiple values, simply by storing all the values in a Perl array. Consider, for example, the following script, which is designed to add email addresses to a subscription list (maybe for an email newsletter?). Here, the user can send as many email addresses as (s)he likes to the script, simply by repeating the "--add" option with different values.
Here's what the output might look like: $ ./editlist.pl --add=me@me.com --add=you@you.com --add=them@them.com What's In A Name? Getopt::Long.pm also supports aliases for options, allowing you to provide users with an alternative, sometimes shorter way of accessing the same option. This is accomplished by placing alternative option names after the first one and separating the various alternatives with pipes (|). Consider the following example, which shows you how:
Here, you can attach any of the options "--color", "--colour", "--c" or $ ./script.pl --color
blog comments powered by Disqus |