FYI... I've worked through my AppConfig/Getopt problems; here's the necessary fix.
The latest release of the Getopt::Long (2.32) module is able to handle hash arguments
linked to code, but the current AppConfig module (1.52) hasn't yet been synced w/ the
fix (so it still suffers from the problem, just in a different way).
For now, here's my short-term workaround for the AppConfig::Getopt module to fix the
problem (i.e. get it to play nice with the updated 2.32 Getopt::Long module). Edit the
AppConfig::Getopt module (AppConfig/Getopt.pm), updating the $linkage variable, within
the '_getopt_state' subroutine, to merge the extra hash value argument back into a
'key=value' pair.
### example fix for AppConfig::Getopt ###
sub _getopt_state {
....<cut>...
#my $linkage = sub { $self->set(@_) };
my $linkage = sub {$_[1] .= "=" . pop() if ( $#_ eq 2 ) ;$self->set(@_)};
### example fix end ###
Hope this helps.
Karl
p.s. Grab the new Getopt::Long module here:
http://search.cpan.org/author/JV/Getopt-Long-2.32/
** p.p.s. The new AppConfig/Getopt::Long-2.32 symptom is that both the key and value
are now passed to the linked subroutine by Getopt::Long as two different arguments,
but AppConfig::State.pm expects them as a combined "key=value" argument -- so now the
VALUE is lost. (Just the opposite of what happens when bound to Getopt::Long-2.19.)
The AppConfig::Getopt fix above will merge the values back into a 'key=value' pair
before shipping them off to AppConfig::State's set() method.
----- Original Message -----
From: Karl Kaufman
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 4:45 PM
Subject: Having problems with AppConfig::Getopt module
Hello,
I'm trying to use the 'AppConfig::Getopt' module to parse my command-line arguments,
assigning the passed values to a hash. It's not working. And I need help.
For example:
# test.pl -pagerdest [EMAIL PROTECTED]
Should result in:
%pagerdest = {
'karl' => '[EMAIL PROTECTED]'
};
but, instead, I end up with:
%pagerdest = {
'[EMAIL PROTECTED]' => undef
};
It looks like there's a problem with how AppConfig is linking the values back from
Getopt::Long. Getopt::Long appears to be stripping out the "key=" portion of the
hash's argument -- if the linkage reference is 'CODE' rather than 'HASH'.
The following code snippet provides an example of how AppConfig is receiving changes
from Getopt::Long; and the example below shows the loss of the hash key from the
arguments.
Any idea how to fix the problem? Or where else to search for an answer?
Thanks in advance.
Regards,
Karl K.
##### code example #####
use Getopt::Long;
$linkage = sub { print "@_\n"; };
Getopt::Long::Configure('debug');
GetOptions("pagerdest=s%" => $linkage);
##### end of code example ######
Example debug output --
# ./test.pl -pagerdest [EMAIL PROTECTED]
GetOpt::Long 2.19 called from package "main".
GetOptionsAl $Revision: 2.20 $
ARGV: (-pagerdest [EMAIL PROTECTED])
autoabbrev=1,bundling=0,getopt_compat=1,order=1,
ignorecase=1,passthrough=0,genprefix="(--|-|\+)".
=> link "pagerdest" to CODE(0xcd370)
=> $opctl{"pagerdest"} = "=s%"
=> option "-pagerdest"
=> find "-pagerdest", prefix="(--|-|\+)"
=> split "-"+"pagerdest"
=> 1 hits (pagerdest) with "pagerdest" out of 1
=> found "=s%" for pagerdest
=> ref($L{pagerdest}) -> CODE
=> &L{pagerdest}("pagerdest", "[EMAIL PROTECTED]")
pagerdest [EMAIL PROTECTED]