Skip Menu |

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

Report information
The Basics
Id: 18002
Status: resolved
Priority: 0/
Queue: Getopt-Euclid

People
Owner: DCONWAY [...] cpan.org
Requestors: dbrewer [...] secondstory.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: v0.0.5
Fixed in: (no value)



Subject: Possible for Getopt-Euclid to report bad arguments without compile abort?
First of all, I discovered this module through the excellent "Perl Best Practices" and I'm finding both the book and the module extremely useful. Thanks! There is only one minor complaint I have about this module. In the _bad_arglist subroutine, if any bad or missing arguments were found, the module uses a "die" to report the problem. In my experience this means that when a user of my program fails to use the defined syntax, in addition to the helpful "Unknown argument" or "Missing required argument" message, the user also gets a very unhelpful: BEGIN failed--compilation aborted at myscript.pl line 4. Line 4 is where I "use Getopt::Euclid;". I made myself a slightly modified version of Getopt::Euclid where the line: die "$msg(Try: $prog_name --help)\n\n"; is replaced by: warn "$msg(Try: $prog_name --help)\n\n"; exit; And this seems to give me the behavior I am looking for. Is there a compelling reason that the module needs to die in this case? If so, is there some way to prevent a finished program that uses this module from reporting a compile error when called with the wrong syntax?
Subject: Re: [rt.cpan.org #18002] Possible for Getopt-Euclid to report bad arguments without compile abort?
Date: Mon, 06 Mar 2006 12:06:09 +1100
To: bug-Getopt-Euclid [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Show quoted text
> First of all, I discovered this module through the excellent "Perl Best > Practices" and I'm finding both the book and the module extremely > useful. Thanks!
You're most welcome. ;-) Show quoted text
> There is only one minor complaint I have about this module. In the > _bad_arglist subroutine, if any bad or missing arguments were found, the > module uses a "die" to report the problem. In my experience this means > that when a user of my program fails to use the defined syntax, in > addition to the helpful "Unknown argument" or "Missing required > argument" message, the user also gets a very unhelpful: > > BEGIN failed--compilation aborted at myscript.pl line 4. > > Line 4 is where I "use Getopt::Euclid;". > > I made myself a slightly modified version of Getopt::Euclid where the line: > > die "$msg(Try: $prog_name --help)\n\n"; > > is replaced by: > > warn "$msg(Try: $prog_name --help)\n\n"; > exit; > > And this seems to give me the behavior I am looking for. Is there a > compelling reason that the module needs to die in this case? If so, is > there some way to prevent a finished program that uses this module from > reporting a compile error when called with the wrong syntax?
I don't know of a way to silence the annoying message, nor indeed of a way to capture the exception that's thrown. So the C<die> is clearly unhelpful. I've changed it as you suggested for the next release. Many thanks, Damian
On Sun Mar 05 20:06:37 2006, damian@conway.org wrote: Show quoted text
> I don't know of a way to silence the annoying message, nor indeed of a > way to > capture the exception that's thrown. So the C<die> is clearly > unhelpful. I've > changed it as you suggested for the next release.
Wow, talk about your fast responses! :-) Thanks! David Brewer
Resolved. Thanks.