Skip Menu |

This queue is for tickets about the Getopt-Long CPAN distribution.

Report information
The Basics
Id: 71286
Status: resolved
Priority: 0/
Queue: Getopt-Long

People
Owner: jv [...] cpan.org
Requestors: van.de.bugger [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Unknown config parameter "long_prefix_pattern"
Date: Tue, 27 Sep 2011 22:56:33 +0400
To: bug-Getopt-Long [...] rt.cpan.org
From: Van de Bugger <van.de.bugger [...] gmail.com>
Perl v5.12, Getopt::Long v2.38. Getopt::Long::Configure( qw{ long_prefix_pattern } ); causes error message Getopt::Long: unknown config parameter "long_prefix_pattern" at /usr/share/perl5/Getopt/Long.pm line 1371. There are two problems: 1. long_prefix_pattern is described in the documentation, why it is unknown? 2. Why error reported in the Long.pm line 1371? If it is unknown configuration parameter, it is my mistake, error should be reported in my code, not the code of Getopt::Long. --- Studying Getopt::Long source code I found the value for long_prefix_pattern configuration parameter is mandatory, and missed value causes this error. Thus, current error message is misleading and confusing. If value for long_prefix_pattern is really mandatory, I would like error message clearly states it. --- Background: In my script I wanted to use "two-pass" command line parser: 1. "First pass" parses usual command-line options with a help from Getopt::Long. 2. "Second pass" interprets arguments in order of appearance and executes them as commands. However, I wanted my script recognizes abbreviated commands, ensures commands have mandatory arguments (like file=filename) etc. I though Getopt::Long may do this job if I configure it: long_prefix_pattern= no_permute. --- Thanks anyway. I use Getopt::LOng for many years, it is the first issue I faced in this module. Van.
CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #71286] Unknown config parameter "long_prefix_pattern"
Date: Tue, 27 Sep 2011 21:10:01 +0200
To: bug-Getopt-Long [...] rt.cpan.org
From: Johan Vromans <jvromans [...] squirrel.nl>
[Quoting Van de Bugger via RT, on September 27 2011, 14:56, in "[rt.cpan.org #71286]"] Show quoted text
> 1. long_prefix_pattern is described in the documentation, why it is > unknown?
The message is sligtly off. It should indicate that the parameter is unknown, or incorrectly used. In this case, long_prefix_pattern requires a value, so the option was incorrectly used. I've fixed the message. Show quoted text
> 2. Why error reported in the Long.pm line 1371? If it is unknown > configuration parameter, it is my mistake, error should be reported in > my code, not the code of Getopt::Long.
The message shouldn't include a line number. I've fixed this. Show quoted text
> In my script I wanted to use "two-pass" command line parser: > > 1. "First pass" parses usual command-line options with a help from > Getopt::Long. > > 2. "Second pass" interprets arguments in order of appearance and > executes them as commands. However, I wanted my script recognizes > abbreviated commands, ensures commands have mandatory arguments (like > file=filename) etc. I though Getopt::Long may do this job if I configure > it: long_prefix_pattern= no_permute.
I think long_prefix_pattern is not a viable way to obtain this. pass_through may be a better alternative. -- Johan
Subject: Re: [rt.cpan.org #71286] Unknown config parameter "long_prefix_pattern"
Date: Tue, 27 Sep 2011 23:21:36 +0400
To: bug-Getopt-Long [...] rt.cpan.org
From: Van de Bugger <van.de.bugger [...] gmail.com>
On Tue, 2011-09-27 at 15:10 -0400, jvromans@squirrel.nl via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=71286 > > > [Quoting Van de Bugger via RT, on September 27 2011, 14:56, in "[rt.cpan.org #71286]"]
> > 1. long_prefix_pattern is described in the documentation, why it is > > unknown?
> > The message is sligtly off. It should indicate that the parameter is > unknown, or incorrectly used. In this case, long_prefix_pattern > requires a value, so the option was incorrectly used. > I've fixed the message.
Ok, thanks. BTW, did you notice "prefix" and "prefix_pattern" have the same issue? Show quoted text
>
> > 2. Why error reported in the Long.pm line 1371? If it is unknown > > configuration parameter, it is my mistake, error should be reported in > > my code, not the code of Getopt::Long.
> > The message shouldn't include a line number. I've fixed this. >
> > In my script I wanted to use "two-pass" command line parser: > > > > 1. "First pass" parses usual command-line options with a help from > > Getopt::Long. > > > > 2. "Second pass" interprets arguments in order of appearance and > > executes them as commands. However, I wanted my script recognizes > > abbreviated commands, ensures commands have mandatory arguments (like > > file=filename) etc. I though Getopt::Long may do this job if I configure > > it: long_prefix_pattern= no_permute.
> > I think long_prefix_pattern is not a viable way to obtain this. > pass_through may be a better alternative.
pass_through? Do not see how it can help. I slightly fixed my code to avoid empty value for long_prefix_pattern: Getopt:Long::GetOptions( options ); # First pass, process options. Getopt::Long::Configure( qw{ prefix_pattern=() long_prefix_pattern=() no_permute } ); Getopt::Long( commands ); # Second pass, process commands. It seems it meets my needs and works as I expect. Show quoted text
> -- Johan >
Van.