[ic] Shipping calculation bug

Mike Heins mike at perusion.com
Wed Aug 30 12:16:59 EDT 2006


Quoting Mike Heins (mike at perusion.com):
> 
> Index: Util.pm
> ===================================================================
> RCS file: /var/cvs/interchange/lib/Vend/Util.pm,v
> retrieving revision 2.95
> diff -u -r2.95 Util.pm
> --- Util.pm	16 Aug 2006 13:34:09 -0000	2.95
> +++ Util.pm	30 Aug 2006 15:28:44 -0000
> @@ -892,13 +892,14 @@
>  sub get_option_hash {
>  	my $string = shift;
>  	my $merge = shift;
> -	if (ref $string) {
> -		return $string unless ref $merge;
> +	if (ref $string eq 'HASH') {
> +		my $ref = %$string;
> +		return $ref unless ref $merge;
>  		for(keys %{$merge}) {
> -			$string->{$_} = $merge->{$_}
> -				unless defined $string->{$_};
> +			$ref->{$_} = $merge->{$_}
> +				unless defined $ref->{$_};
>  		}
> -		return $string;
> +		return $ref;
>  	}
>  	return {} unless $string and $string =~ /\S/;
>  	$string =~ s/^\s+//;
> 
> I believe the value of the option is getting modified in place,
> and that this should solve that.

Sorry, bad patch -- use this instead:

Index: Util.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Util.pm,v
retrieving revision 2.95
diff -u -r2.95 Util.pm
--- Util.pm	16 Aug 2006 13:34:09 -0000	2.95
+++ Util.pm	30 Aug 2006 16:16:20 -0000
@@ -892,13 +892,14 @@
 sub get_option_hash {
 	my $string = shift;
 	my $merge = shift;
-	if (ref $string) {
-		return $string unless ref $merge;
+	if (ref $string eq 'HASH') {
+		my $ref = { %$string };
+		return $ref unless ref $merge;
 		for(keys %{$merge}) {
-			$string->{$_} = $merge->{$_}
-				unless defined $string->{$_};
+			$ref->{$_} = $merge->{$_}
+				unless defined $ref->{$_};
 		}
-		return $string;
+		return $ref;
 	}
 	return {} unless $string and $string =~ /\S/;
 	$string =~ s/^\s+//;
-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Fast, reliable, cheap.  Pick two and we'll talk.  -- unknown


More information about the interchange-users mailing list