Name

getopts

Synopsis

getopts ('switches'[, \%opts])

Like getopt, except that all valid options are included in switches, and options that take an argument are followed by a colon (:). For example:

getopt('oDI')    # -o, -D, & -I take arguments; there may 
                 # be other options
getopts('o:DI')  # -o, -D, and -I are the only valid 
                 # options; only -o takes an argument

\% opts means the same as with getopt.

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.