~ubuntu-branches/ubuntu/intrepid/perl-doc-html/intrepid

« back to all changes in this revision

Viewing changes to Getopt/Std.html

  • Committer: Bazaar Package Importer
  • Author(s): Roberto C. Sanchez
  • Date: 2008-05-17 20:14:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080517201419-qgbuogq2ckkdisyi
Tags: 5.10.0-2
Supersede botched upload of 5.10.0-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
      <h2>Links:</h2>
55
55
      <ul>
56
56
        <li><a href="http://search.cpan.org">CPAN</a></li>
 
57
        <li><a href="http://www.perl.org">Perl.org</a></li>
57
58
        <li><a href="http://www.perl.com">Perl.com</a></li>
58
 
        <li><a href="http://www.perl.org">Perl.org</a></li>
 
59
        <li><a href="http://perlbuzz.com">Perl Buzz</a></li>
 
60
        <li><a href="http://www.perlfoundation.org/perl5/index.cgi">Perl 5 Wiki</a></li>
 
61
        <li><a href="http://jobs.perl.org">Perl Jobs</a></li>
59
62
        <li><a href="http://www.pm.org">Perl Mongers</a></li>
60
63
        <li><a href="http://www.perlmonks.org">Perl Monks</a></li>
61
64
        <li><a href="http://planet.perl.org">Planet Perl</a></li>
65
68
      <ul>
66
69
        <li>Site maintained by<br><a href="http://perl.jonallen.info">Jon Allen</a>
67
70
            (<a href="http://perl.jonallen.info">JJ</a>)</li>
68
 
        <li class="spaced">Last updated on<br>23 April 2006</li>
 
71
        <li class="spaced">Last updated on<br>23 December 2007</li>
69
72
        <li class="spaced">See the <a href="http://perl.jonallen.info/projects/perldoc">project page</a> for
70
73
        more details</li>
71
74
      </ul>
76
79
    <div id="centerContent">
77
80
      <div id="contentHeader">
78
81
        <div id="contentHeaderLeft"><a href="#" onClick="showLeft()">Show navigation</a></div>
79
 
        <div id="contentHeaderCentre">-- Perl 5.8.8 documentation --</div>
 
82
        <div id="contentHeaderCentre">-- Perl 5.10.0 documentation --</div>
80
83
        <div id="contentHeaderRight"><a href="#" onClick="showRight()">Show toolbar</a></div>
81
84
      </div>
82
85
      <div id="breadCrumbs"><a href="../index.html">Home</a> &gt; <a href="../index-modules-A.html">Core modules</a> &gt; <a href="../index-modules-G.html">G</a> &gt; Getopt::Std</div>
83
86
      <script language="JavaScript">fromSearch();</script>
84
 
      <div id="contentBody"><div class="title_container"><div class="page_title">Getopt::Std</div></div><ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#'--help'-and-'--version'"><code class="inline">--help</code>
85
 
 and <code class="inline">--version</code>
 
87
      <div id="contentBody"><div class="title_container"><div class="page_title">Getopt::Std</div></div><ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#'--help'-and-'--version'"><code class="inline">--<span class="w">help</span></code>
 
88
 and <code class="inline">--<span class="w">version</span></code>
86
89
</a></ul><a name="NAME"></a><h1>NAME</h1>
87
90
<p>getopt, getopts - Process single-character switches with switch clustering</p>
88
91
<a name="SYNOPSIS"></a><h1>SYNOPSIS</h1>
89
 
<pre class="verbatim">    <a class="l_k" href="../functions/use.html">use</a> <a class="l_w" href="../Getopt/Std.html">Getopt::Std</a><span class="sc">;</span></pre>
 
92
<pre class="verbatim">    <a class="l_k" href="../functions/use.html">use</a> <span class="w">Getopt::Std</span><span class="sc">;</span></pre>
90
93
<pre class="verbatim">    <span class="i">getopt</span><span class="s">(</span><span class="q">&#39;oDI&#39;</span><span class="s">)</span><span class="sc">;</span>    <span class="c"># -o, -D &amp; -I take arg.  Sets $opt_* as a side effect.</span>
91
94
    <span class="i">getopt</span><span class="s">(</span><span class="q">&#39;oDI&#39;</span><span class="cm">,</span> \<span class="i">%opts</span><span class="s">)</span><span class="sc">;</span>    <span class="c"># -o, -D &amp; -I take arg.  Values in %opts</span>
92
95
    <span class="i">getopts</span><span class="s">(</span><span class="q">&#39;oif:&#39;</span><span class="s">)</span><span class="sc">;</span>  <span class="c"># -o &amp; -i are boolean flags, -f takes an argument</span>
101
104
there is a space between the switch and the argument.</p>
102
105
<p>The getopts() function is similar, but you should pass to it the list of all
103
106
switches to be recognized.  If unspecified switches are found on the
104
 
command-line, the user will be warned that an unknown option was given.</p>
105
 
<p>Note that, if your code is running under the recommended <code class="inline"><a class="l_k" href="../functions/use.html">use</a> <a class="l_w" href="../strict.html">strict</a>
 
107
command-line, the user will be warned that an unknown option was given.
 
108
The getopts() function returns true unless an invalid option was found.</p>
 
109
<p>Note that, if your code is running under the recommended <code class="inline"><a class="l_k" href="../functions/use.html">use</a> <span class="w">strict</span>
106
110
<span class="q">&#39;vars&#39;</span></code>
107
111
 pragma, you will need to declare these package variables
108
112
with "our":</p>
116
120
<code class="inline">--</code>
117
121
.  The <code class="inline">--</code>
118
122
 will be removed from @ARGV.</p>
119
 
<a name="'--help'-and-'--version'"></a><h1><code class="inline">--help</code>
120
 
 and <code class="inline">--version</code>
 
123
<a name="'--help'-and-'--version'"></a><h1><code class="inline">--<span class="w">help</span></code>
 
124
 and <code class="inline">--<span class="w">version</span></code>
121
125
</h1>
122
126
<p>If <code class="inline">-</code>
123
127
 is not a recognized switch letter, getopts() supports arguments
124
 
<code class="inline">--help</code>
125
 
 and <code class="inline">--version</code>
 
128
<code class="inline">--<span class="w">help</span></code>
 
129
 and <code class="inline">--<span class="w">version</span></code>
126
130
.  If <code class="inline"><span class="i">main::HELP_MESSAGE</span><span class="s">(</span><span class="s">)</span></code>
127
131
 and/or
128
132
<code class="inline"><span class="i">main::VERSION_MESSAGE</span><span class="s">(</span><span class="s">)</span></code>
131
135
and the switches string.  If the subroutines are not defined, an attempt is
132
136
made to generate intelligent messages; for best results, define $main::VERSION.</p>
133
137
<p>If embedded documentation (in pod format, see <a href="../perlpod.html">perlpod</a>) is detected
134
 
in the script, <code class="inline">--help</code>
 
138
in the script, <code class="inline">--<span class="w">help</span></code>
135
139
 will also show how to access the documentation.</p>
136
140
<p>Note that due to excessive paranoia, if $Getopt::Std::STANDARD_HELP_VERSION
137
141
isn't true (the default is false), then the messages are printed on STDERR,
139
143
the opposite of the standard-conforming behaviour, it is strongly recommended
140
144
to set $Getopt::Std::STANDARD_HELP_VERSION to true.</p>
141
145
<p>One can change the output file handle of the messages by setting
142
 
$Getopt::Std::OUTPUT_HELP_VERSION.  One can print the messages of <code class="inline">--help</code>
 
146
$Getopt::Std::OUTPUT_HELP_VERSION.  One can print the messages of <code class="inline">--<span class="w">help</span></code>
143
147
 
144
148
(without the <code class="inline"><span class="j">Usage:</span></code>
145
 
 line) and <code class="inline">--version</code>
 
149
 line) and <code class="inline">--<span class="w">version</span></code>
146
150
 by calling functions help_mess()
147
151
and version_mess() with the switches string as an argument.</p>
148
152
</div>
162
166
          <!--<select name="r"><option value="1" selected>Go to top result<option value="0">Show results list</select>-->
163
167
        </form>
164
168
      </p>
 
169
      <script language="JavaScript" type="text/javascript" src="/perl-version.js"></script>
165
170
      <h2>Labels:</h2>
166
171
      <p>
167
172
        <a href="#" onClick="addLabel('Getopt::Std','Getopt/Std.html')">Add this page</a>