develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #116098] Error in Getopt::Std documentation examples

Thread Previous
From:
James E Keenan via RT
Date:
May 19, 2013 23:18
Subject:
[perl #116098] Error in Getopt::Std documentation examples
Message ID:
rt-3.6.HEAD-2650-1369005478-1462.116098-15-0@perl.org
On Sat May 11 13:24:19 2013, rrt wrote:
> On 11 May 2013 03:03, Ronald J Kimball via RT <perlbug-
> followup@perl.org>wrote:
> 
> > On Fri, May 10, 2013 at 04:56:28PM -0700, James E Keenan via RT
> wrote:
> >
> > > Thanks for the patch.  List, can we get this reviewed?
> >
> > This patch looks fine to me.
> >
> 
> I just noticed that it should reverse the order of the functions in
> the
> SYNOPSIS section. Revised patch:
> 
> From 81a8b72b242110d81f17b8f002604fd722aa69f2 Mon Sep 17 00:00:00 2001
> From: Reuben Thomas <rrt@sc3d.org>
> Date: Fri, 10 May 2013 13:05:13 +0100
> Subject: [PATCH] Document getopts before getopt, and de-recommend
> getopt.
> 
> ---
>  lib/Getopt/Std.pm | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/Getopt/Std.pm b/lib/Getopt/Std.pm
> index d4ce9a3..841c0c7 100644
> --- a/lib/Getopt/Std.pm
> +++ b/lib/Getopt/Std.pm
> @@ -10,25 +10,27 @@ getopt, getopts - Process single-character
> switches
> with switch clustering
> 
>      use Getopt::Std;
> 
> -    getopt('oDI');    # -o, -D & -I take arg.  Sets $opt_* as a side
> effect.
> -    getopt('oDI', \%opts);    # -o, -D & -I take arg.  Values in
> %opts
>      getopts('oif:');  # -o & -i are boolean flags, -f takes an
> argument
>                # Sets $opt_* as a side effect.
>      getopts('oif:', \%opts);  # options as above. Values in %opts
> +    getopt('oDI');    # -o, -D & -I take arg.  Sets $opt_* as a side
> effect.
> +    getopt('oDI', \%opts);    # -o, -D & -I take arg.  Values in
> %opts
> 
>  =head1 DESCRIPTION
> 
> -The getopt() function processes single-character switches with switch
> +The getopts() function 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 $opt_x (where x
> is the
> +to be recognized.  For each switch found, sets $opt_x (where x is the
>  switch name) to the value of the argument if an argument is expected,
>  or 1 otherwise.  Switches which take an argument don't care whether
> -there is a space between the switch and the argument.
> -
> -The getopts() function is similar, but you should pass to it the list
> of
> all
> -switches to be recognized.  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.
> +there is a space between the switch 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.
> +
> +The getopt() function is similar, but its argument is a string
> containing
> +all switches that take an argument.  Unspecified switches are
> silently
> +accepted.  Its use is not recommended.
> 
>  Note that, if your code is running under the recommended C<use strict
>  'vars'> pragma, you will need to declare these package variables


I tried applying this patch, but it failed.  I suspect that the failure
was due to the fact that the patch was included inline and I had to try
to copy and paste it into a file.

Would it be possible to re-pull the patch against blead and attach it to
this RT rather than including it in the body of your message.

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=116098

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About