Subject: | Unexpected results with notation =item -F and =item -[T|template] |
My login prompt is 'Black JL: '. This is a transcript of a session,
including the complete test script.
=====================================
Black JL: cat test.minimalist
wc -l minimalist.pl
perl minimalist.pl --usage
perl minimalist.pl --help
perl minimalist.pl -F
perl minimalist.pl -s server
perl minimalist.pl -R parameter
perl minimalist.pl -T tocemma
perl minimalist.pl -template tocemma
cat minimalist.pl
Black JL: sh -x test.minimalist
+ wc -l minimalist.pl
108 minimalist.pl
+ perl minimalist.pl --usage
Usage: minimalist.pl [options]
minimalist.pl --help
+ perl minimalist.pl --help
Usage:
minimalist.pl [options]
Options:
-[T|template] [=] <template>
Template file (default $INFORMIXDIR/etc/onconfig.std).
-F Create files as needed
-s[ervername] [=] <servername>
Specify the (principal) server name.
-[R|delete] <PARAM>
Remove (or delete) named parameter from the $ONCONFIG file.
--version
--usage
--help
--man
To print the version, usage, help and manual.
+ perl minimalist.pl -F
-T = F
- = <template = F
-template = F
- <template = F
+ perl minimalist.pl -s server
-s = server
-servername = server
+ perl minimalist.pl -R parameter
Unknown argument: parameter
(Try: minimalist.pl --help)
+ perl minimalist.pl -T tocemma
Unknown argument: tocemma
(Try: minimalist.pl --help)
+ perl minimalist.pl -template tocemma
Unknown argument: tocemma
(Try: minimalist.pl --help)
+ cat minimalist.pl
#!/bin/perl -w
#
# @(#)$Id: onconfig.pl,v 2007.1 2007/10/09 08:25:16 jleffler Exp
jleffler $
#
# Demonstrator for Getopt::Euclid
#
# Options
# -F Make files as needed
# -T file Template - defaulting to $INFORMIXDIR/etc/onconfig.std
# -S param=value Substitute new value for parameter
# -s srvr $INFORMIXSERVER
use strict;
use Getopt::Euclid;
use constant debug => 1;
if (debug)
{
foreach my $key (keys %ARGV)
{
print "$key = $ARGV{$key}\n";
}
}
__END__
=pod
=head1 NAME
minimalist - Demonstrator for Getopt::Euclid
=head1 VERSION
$Revision: 0.01 $
=head1 USAGE
Best obtained by using the --help option.
=head1 OPTIONS
=over
=item -[T|template] [=] <template>
Template file (default $INFORMIXDIR/etc/onconfig.std).
=for Euclid:
template.type: string
=item -F
Create files as needed
=item -s[ervername] [=] <servername>
Specify the (principal) server name.
=for Euclid:
servername.type: string
=item -[R|delete] <PARAM>
Remove (or delete) named parameter from the $ONCONFIG file.
=for Euclid:
repeatable
PARAM.type: string
=item --version
=item --usage
=item --help
=item --man
To print the version, usage, help and manual.
=back
=head1 DESCRIPTION
Originally, this was going generate a customized but workable
ONCONFIG script for IBM Informix Dynamic Server or IDS, using a template
and applying changes specified by the command line arguments.
It has now morphed into a test bed for establishing whether there are
problems with Getopt::Euclid and reporting them if necessary.
=head1 COPYRIGHT
Copyright 2007 Jonathan Leffler.
This program is licenced under the same terms as Perl; that is,
it is licenced under the terms of the GNU General Public License,
or under the terms of the Perl Artistic License.
=head1 BUGS
There are undoubtedly serious bugs lurking somewhere in this code.
Bug reports and other feedback are most welcome.
=head1 AUTHOR
Jonathan Leffler (C<jleffler@us.ibm.com>)
=cut
Black JL:
=====================================
Background: I attempted to convert a large, pre-existing program that
used Getopt::Std with single-letter options throughout because I want
the cumulative option processing that Getopt::Euclid provides. Some
options work as expected: the '=item -s[ervername] [=] <servername>' is
behaving immaculately (and is included to demonstrate that some stuff
works as expected).
I don't understand how/why the '=item -F' option is working; I expected
it to set $ARGV{-F} to a true value.
I think the other two options are just broken - but I'm not certain
whether the breakage is in my expectations or in the Getop::Euclid code.
I was expecting that '=item -[T|template] [=] <template>' notation would
permit '-T /some/file' or '-template /some/file' and in either case
would set $ARGV{-T} = "/some/file" and $ARGV{-template} = "/some/file".
I was expecting that '=item -[R|delete]' would accept '-R OPTIMIZER' and
would set $ARGV{-R} = "OPTIMIZER" and $ARGV{-delete} = "OPTIMIZER".
I'm not clear whether the use of X11-style single-dash plus long-name
stuff is not supported; the -s option suggests it should be. I suspect
that the trouble is related to -[X|y] where there are two wholly
independent spellings of the option bundled into a single item.
The intent behind the -R option was to allow -R param1 -R param2 on the
command line and to delete both the param1 and param2 lines (the choice
of single letter was dictated by the copious use of other options, and
both -D and -d were already in use for other purposes). I was also
planning to use '=item -[A|add] <PARAM> [=] <value>' but it runs into
similar issues to the -R and -T options. This would be used to add
multiple entries such as '-A WHATNOT=1 -A DOHICKEY=something' to the
configuration file I'm generating. I was expecting/hoping that would
produce a $ARGV{-A} containing an array of hashes, with each hash
containing $hash{PARAM} = "WHATNOT" and $hash{value} = "1" for the first
entry and $hash{PARAM} = "DOHICKEY" and $hash{value} = "something" for
the second.
(Perl 5.8.8 on Solaris 10; Getopt::Euclid 0.1.0 - other details on request).
Interesting side-note (it isn't easy to establish the version of
Getopt::Euclid):
Black JL: perl -MGetopt::Euclid -e 'print "$Getopt::Euclid::VERSION\n";'
Getopt::Euclid was unable to access POD
(No such file or directory)
Problem was at -e line 0
BEGIN failed--compilation aborted.
Black JL: perl -MGetopt::Euclid=999
Unknown mode ('999') at - line 0
BEGIN failed--compilation aborted.
Black JL: perl -MDBI=999
DBI version 999 required--this is only version 1.59 at
/usr/perl/v5.8.8-32bit-sun-cc/lib/5.8.8/Expor
ter/Heavy.pm line 121.
BEGIN failed--compilation aborted.
Black JL:
--
Jonathan Leffler <jleffler@earthlink.net> <j.leffler@acm.org>
Guardian of DBD::Informix 2007.0914 -- see http://dbi.perl.org/
"I don't suffer from insanity - I enjoy every minute of it!"