NAME

EPICS::Getopts - Process single-character command-line options

SYNOPSIS

    use EPICS::Getopts;

    getopts('vo:I@') or die "Bad option\n";
        # -v is a counted flag; -o takes an argument and
        # sets $opt_o to its value; -I may be used more than
        # once, the values are pushed onto @opt_I

DESCRIPTION

This version of getopts has been modified from the Perl original to add functionality that was needed by EPICS Perl applications. Some functionality of the original has also been removed. The main changes were:

FUNCTIONS

getopts($argspec)

The getopts() function processes single-character options. It takes one argument, a string containing all the options that should be recognized. For option letters in the string that are followed by a colon : it sets $opt_x (where x is the option letter) to the value of that argument. For option letters followed by an at sign @ it pushes each subsequent argument onto the array @opt_x (where x is the option letter). For option letters without any qualifier it adds 1 to the value of $opt_x. Options which take an argument don't care whether there is a space between the option and the argument.

If unspecified switches are found on the command-line, the user will be warned that an unknown option was given. The getopts() function returns true unless an invalid option was found.

Note that, if your code is running under the recommended use strict 'vars' pragma, you will need to declare the necesary package variables with "our" before the call to getopts:

    our($opt_v, $opt_o, @opt_I);

To allow programs to process arguments that look like options but aren't, the function will stop processing options when it sees the argument --. The -- will be removed from @ARGV.