The option type decides what action will be taken when this option is seen
on the command line, and (if applicable) what sort of values will be
accepted for this option. There are three broad classes of types: those
that imply copying data from the command line into some variable in the
caller's space; those that imply copying constant data into the caller's
space without taking any more arguments from the command line; and those
that imply some other action to be taken. The available option types are
covered in greater detail below (see <A HREF="#option types">OPTION TYPES</A>), but briefly:
<CODE>string</CODE>, <CODE>integer</CODE>, and <CODE>float</CODE> all imply copying values from the
command line to a variable; <CODE>constant</CODE>, <A HREF="#item_boolean"><CODE>boolean</CODE></A>, <A HREF="#item_copy"><CODE>copy</CODE></A>,
<A HREF="#item_arrayconst"><CODE>arrayconst</CODE></A>, and <A HREF="#item_hashconst"><CODE>hashconst</CODE></A> all imply copying some pre-defined data
into a variable; <A HREF="#item_call"><CODE>call</CODE></A> and <A HREF="#item_eval"><CODE>eval</CODE></A> allow the execution of some arbitrary
subroutine or chunk of code; and <A HREF="#item_help"><CODE>help</CODE></A> options will cause <CODE>GetOptions</CODE>
to print out all available help text and return 0.
for <CODE>string</CODE>, <CODE>integer</CODE>, and <CODE>float</CODE> options, this determines whether
the option is a scalar (<STRONG>num_values</STRONG> = 1) or vector (<STRONG>num_values</STRONG> > 1)
option. (Note that whether the option is scalar- or vector-valued has an
important influence on what you must supply in the <STRONG>option_data</STRONG> field!)
For <CODE>constant</CODE>, <A HREF="#item_copy"><CODE>copy</CODE></A>, <A HREF="#item_arrayconst"><CODE>arrayconst</CODE></A>, and <A HREF="#item_hashconst"><CODE>hashconst</CODE></A> option types,
<STRONG>num_values</STRONG> is a bit of a misnomer: it actually contains the value (or a
reference to it, if array or hash) to be copied when the option is
encountered. For <A HREF="#item_call"><CODE>call</CODE></A> options, <STRONG>num_values</STRONG> can be used to supply
extra arguments to the called subroutine. In any case, though, you can
think of <STRONG>num_values</STRONG> as an input value. For <A HREF="#item_boolean"><CODE>boolean</CODE></A> and <A HREF="#item_eval"><CODE>eval</CODE></A>
options, <STRONG>num_values</STRONG> is ignored and should be <A HREF="../../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A> or 0.
For <CODE>string</CODE>, <CODE>integer</CODE>, <CODE>float</CODE>, <A HREF="#item_boolean"><CODE>boolean</CODE></A>, <CODE>constant</CODE>, <A HREF="#item_copy"><CODE>copy</CODE></A>,
<A HREF="#item_arrayconst"><CODE>arrayconst</CODE></A>, and <A HREF="#item_hashconst"><CODE>hashconst</CODE></A> types, this must be a reference to the
variable into which you want <CODE>GetOptions</CODE> to copy the appropriate thing.
The ``appropriate thing'' is either the <A HREF="#item_argument"><CODE>argument(s)</CODE></A> following the option, the
constant supplied as <STRONG>num_values</STRONG>, or 1 or 0 (for boolean options).
<P>For <A HREF="#item_boolean"><CODE>boolean</CODE></A>, <CODE>constant</CODE>, <A HREF="#item_copy"><CODE>copy</CODE></A>, and scalar-valued <CODE>string</CODE>,
<CODE>integer</CODE>, and <CODE>float</CODE> options, this must be a scalar reference. For
vector-valued <CODE>string</CODE>, <CODE>integer</CODE>, and <CODE>float</CODE> options (<STRONG>num_values</STRONG> >
1), and for <A HREF="#item_arrayconst"><CODE>arrayconst</CODE></A> options, this must be an array reference. For
<A HREF="#item_hashconst"><CODE>hashconst</CODE></A> options, this must be a hash reference.</P>
<P>Finally, <STRONG>option_data</STRONG> is also used as an input value for <A HREF="#item_call"><CODE>call</CODE></A> and
<A HREF="#item_eval"><CODE>eval</CODE></A> options: for <A HREF="#item_call"><CODE>call</CODE></A>, it should be a subroutine reference, and for
<A HREF="#item_eval"><CODE>eval</CODE></A> options, it should be a string containing valid Perl code to
evaluate when the option is seen. The subroutine called by a <A HREF="#item_call"><CODE>call</CODE></A>
option should take at least two arguments: a string, which is the actual
option that triggered the call (because the same subroutine could be tied
to many options), and an array reference, which contains all command line
arguments after that option. (Further arguments can be supplied in the
<STRONG>num_values</STRONG> field.) The subroutine may freely modify this array, and
those modifications will affect the behaviour of <CODE>GetOptions</CODE> afterwards.</P>
<P>The chunk of code passed to an <A HREF="#item_eval"><CODE>eval</CODE></A> option is evaluated in the package
from which <CODE>GetOptions</CODE> is called, and does not have access to any
<STRONG>copy</STRONG> options act just like <STRONG>const</STRONG> options, except when
<STRONG>num_values</STRONG> is undefined. In that case, the option name itself will
be copied to the scalar referenced by <STRONG>option_data</STRONG>, rather than the
<A HREF="../../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A> value that would be copied under these circumstances with a
<STRONG>const</STRONG> option. This is useful when one program accepts options that
it simply passes to a sub-program; for instance, if <EM>prog1</EM> calls
<EM>prog2</EM>, and <EM>prog2</EM> might be run with the -foo option, then
<EM>prog1</EM>'s argument table might have this option:
<PRE>
["-foo", "copy", undef, \$Foo,
"run prog2 with the -foo option"]</PRE>
<P>and later on, you would run <EM>prog2</EM> like this:</P>
<PRE>
system ("prog2 $Foo ...");</PRE>
<P>That way, if <CODE>-foo</CODE> is never seen on <EM>prog1</EM>'s command line, <CODE>$Foo</CODE> will
be untouched, and will expand to the empty string when building the command
line for <EM>prog2</EM>.</P>
<P>If <STRONG>num_values</STRONG> is anything other than <A HREF="../../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A>, then <STRONG>copy</STRONG> options
behave just like <STRONG>constant</STRONG> options.</P>