This package provides the routine 'getargs' for parsing command line arguments. It automates most of a standard command line interface by taking a picture of the expected arguments of the form: ( <4tuple> [, <4tuple> ]... ) <4tuple> ::= , , , ::= '-' for switch arguments (these are order independent among themselves, but must all appear before any positional arguments) 'm' for mandatory positional arguments 'o' for optional positional arguments 'h' provides the help text; keyword and size are ignored. The contents of the scalar named in the variable are saved to print in the usage message. This may appear anywhere in the argument picture, but only one may be specified. ::= string to match for switch arguments (also used to print for usage of postional arguments) To provide a short form and long form for an argument, use '|'; the long form will be recognized only if preceded by a double dash. For example: '-', 'f|force' specifies the switches '-f' and '--force' as being equivalent. ::= number of values to consume from ARGV 0 ::= increment variable using '++' (used for flag switches) >1 ::= set list variable to next 'n' values -1 ::= set list variable to remaining values (for switch arguments, the values following '--' are not consumed) ::= name of variable (not including $ or @) to assign argument value into Provides -usage, --usage, -help, --help, and -? (if the 'usage' or 'help' switches are specified in the picture, the caller will get it like any other switch). Provides '--' for the end of switch arguments. Switch and Optional arguments not specified in @ARGV are not defined by getargs - you can either test for that or just assign them default values before calling getargs. @ARGV is not modified. The getargs routine can be used for interactive command parsing by reading the command, splitting the results into @ARGV, and calling getargs as you would for the real command line. Returns 1 if @ARGV parsed correctly according to the picture; if not, it prints the usage message and returns 0; Example: $HelpText = <<_HELP_TEXT_; This is the help text for this command. _HELP_TEXT_ &getargs( '-', 'flag', 0, 'Flag' ,'-', 'value', 1, 'Value' ,'-', 'list', 2, 'List' ,'-', 'a|alternate', 1, 'Alternate' ,'-', 'values', -1, 'Values' ,'m', 'mandatory', 1, 'Mandatory' ,'m', 'mandatory2', 1, 'Mandatory2' ,'o', 'optional', 1, 'Optional' ,'h', '', 0, 'HelpText' ) || exit; Produces the usage picture: ############################################################# testargs [-flag] [-value ] [-list ] [-a|--alternate ] [-values ... ] [--] [] This is the help text for this command. ############################################################# and sets the variables: $Mandatory, $Mandatory2 and (if specified): $Flag, $Value, @List, $Alternate, @Values, $Optional