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?