From: Piotr Roszatycki Date: Fri, 14 Nov 2008 00:48:55 +0000 (+0000) Subject: * MooseX::Getopt::Parser::Long: Operate on options copy. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=354c610a96f91d76932428e403690a64f4bd906c;hp=10ed52cb080cfbe757fdb2a4c7ceb463fba93e6c;p=gitmo%2FMooseX-Getopt.git * MooseX::Getopt::Parser::Long: Operate on options copy. * MooseX::Getopt: Bump version to 0.150001. --- diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 0e4a268..fae2483 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -12,7 +12,7 @@ use MooseX::Getopt::Meta::Attribute; use MooseX::Getopt::Meta::Attribute::NoGetopt; -our $VERSION = '0.15'; +our $VERSION = '0.150001'; our $AUTHORITY = 'cpan:STEVAN'; diff --git a/lib/MooseX/Getopt/Parser/Long.pm b/lib/MooseX/Getopt/Parser/Long.pm index fb369ce..d0342ce 100644 --- a/lib/MooseX/Getopt/Parser/Long.pm +++ b/lib/MooseX/Getopt/Parser/Long.pm @@ -26,6 +26,8 @@ sub build_options { unless $getopt->isa('MooseX::Getopt::Session'); my $options = $getopt->options; + my $new_options = { %$options }; + my @opts; foreach my $attr (@attrs) { @@ -37,8 +39,8 @@ sub build_options { my $opt_string = join '|', $flag, @aliases; $opt_string .= MooseX::Getopt::OptionTypeMap->get_option_type($type) if $type; - $options->{$name} = undef; - push @opts, $opt_string => \$options->{$name}; + $new_options->{$name} = undef; + push @opts, $opt_string => \$new_options->{$name}; }; my $warnings = ''; @@ -60,14 +62,14 @@ sub build_options { $getopt->extra_argv( $extra_argv ); }; - # Filter not defined values in options hashref - $options = { map { $_ => $options->{$_} } grep { defined $options->{$_} } keys %$options }; + # Filter not defined values in new_options hashref + $new_options = { map { $_ => $new_options->{$_} } grep { defined $new_options->{$_} } keys %$new_options }; - $getopt->options( $options ); + $getopt->options( $new_options ); die $warnings if $warnings; - return $options; + return $new_options; };