From: Yuval Kogman Date: Sat, 2 Feb 2008 18:17:38 +0000 (+0000) Subject: Getopt::Long processes all option names, do the same in the name_to_init_arg index X-Git-Tag: 0_15~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=41d0ab091f0df3e2c1eae2401545c07c3798f76f;p=gitmo%2FMooseX-Getopt.git Getopt::Long processes all option names, do the same in the name_to_init_arg index --- diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 7d48fd4..98a7221 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -107,7 +107,11 @@ sub _traditional_spec { foreach my $opt ( @{ $params{options} } ) { push @options, $opt->{opt_string}; - $name_to_init_arg{ $opt->{name} } = $opt->{init_arg}; + + my $identifier = $opt->{name}; + $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names + + $name_to_init_arg{$identifier} = $opt->{init_arg}; } return ( \@options, \%name_to_init_arg ); @@ -128,7 +132,10 @@ sub _gld_spec { }, ]; - $name_to_init_arg{ $opt->{name} } = $opt->{init_arg}; + my $identifier = $opt->{name}; + $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names + + $name_to_init_arg{$identifier} = $opt->{init_arg}; } return ( \@options, \%name_to_init_arg );