[ic] Perl tag bug - problem converting strings to numbers

Bryan tquark at gmail.com
Fri Nov 5 18:15:06 EST 2004


Hi,

I think I found a bug in the [perl] tag.
Basically perl is not converting strings to numbers properly
E.g. this:
..
      [set mysub][subtotal noformat=1][/set]
      [perl failure=".."]
                        my $amount_min_ord = $Scratch->{amount_min_ord};
                        my $mysubtotal = $Scratch->{mysub};
                        $mysubtotal = $mysubtotal + 0.01;
                        $out .= $amount_min_ord." ".$mysubtotal;
                        return $out;
        [/perl]

Returns
75.00 0.01 
When it should return 75.00 108.01.  
(there is $108 worth of stuff in the cart)
However, if I just remove the $mysubtotal = $mysubtotal+1 line then it
returns what you'd expect
75.00 108

The same sort of thing happens if I try
      [perl failure=".."]
                        my $amount_min_ord = 1.00*$Scratch->{amount_min_ord};
                        my $mysubtotal = 1.00*$Scratch->{mysub};
                        $out .= $amount_min_ord." ".$mysubtotal;
                        return $out;
        [/perl]
Returns:
75.00 0

Now, the problem is that I want to do:
      [perl failure=".."]
                        my $amount_min_ord = $Scratch->{amount_min_ord};
                        my $mysubtotal = $Scratch->{mysub};
                        if($amount_min_ord > $mysubtotal){
                               # then do stuff
                        }
                        else{
                                # then do other stuff
                        }
                        return $out;
        [/perl]

But this if statement is always true whether or not [subtotal] is
greater than or less than $amount_min_ord

I'm running IC 5.2 and perl 5.8.5

Can anyone suggest a workaround/fix to the core?

Thanks!
Bryan


More information about the interchange-users mailing list