<?xml version="1.0" encoding="windows-1252"?>
<node id="1212" title="perlman:Getopt::Std" created="1999-12-22 19:51:54" updated="2005-08-13 10:37:20">
<type id="119">
perlfunc</type>
<author id="113">
root</author>
<data>
<field name="doctext">
</field>
<field name="name">

&lt;P&gt;
getopt - Process single-character switches with switch clustering

&lt;P&gt;
getopts - Process single-character switches with switch clustering

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="synopsis">

&lt;P&gt;
&lt;PRE&gt;    use Getopt::Std;
&lt;/PRE&gt;
&lt;P&gt;
&lt;PRE&gt;    getopt('oDI');    # -o, -D &amp;amp; -I take arg.  Sets opt_* as a side effect.
    getopt('oDI', \%opts);    # -o, -D &amp;amp; -I take arg.  Values in %opts
    getopts('oif:');  # -o &amp;amp; -i are boolean flags</field>
<field name="description">

&lt;P&gt;
The 
&lt;CODE&gt;getopt()&lt;/CODE&gt; functions processes
single-character switches with switch clustering. Pass one argument which
is a string containing all switches that take an argument. For each switch
found, sets &lt;CODE&gt;$opt_x&lt;/CODE&gt; (where x is the switch name) to the value
of the argument, or 1 if no argument. Switches which take an argument don't
care whether there is a space between the switch and the argument.

&lt;P&gt;
Note that, if your code is running under the recommended &lt;CODE&gt;use strict
'vars'&lt;/CODE&gt; pragma, it may be helpful to declare these package variables via &lt;CODE&gt;use vars&lt;/CODE&gt; perhaps something like this:

&lt;P&gt;
&lt;PRE&gt;    use vars qw/ $opt_foo $opt_bar /;
&lt;/PRE&gt;
&lt;P&gt;
For those of you who don't like additional variables being created, 
&lt;CODE&gt;getopt()&lt;/CODE&gt; and 
&lt;CODE&gt;getopts()&lt;/CODE&gt; will also accept a hash reference as an optional second argument. Hash keys will be x (where x is the switch name) with key values the value of the argument or 1 if no argument is specified.

&lt;HR&gt;
</field>
</data>
</node>
