in reply to Unwanted implicit conversion to float

In this case sprintf is your friend (and coming from a C background an asset). It might slow you down somehow but if you throw in $val= sprintf( "%f6.2", $val); before using $val, you will get back the proper precision.

Here is an example:

#!/usr/bin/perl -w use strict; my @rows=<DATA>; my $val=0; for (@rows) { chomp; if (/([\d.]+)/) { $val += $1; $val= sprintf( "%6.2f", $val); warn "Added $1 from $_ and set it to $val\n"; } } __DATA__ we get to $6257.65 now we add $33.4099999999999999 we add $37.24

outputs:

Added 6257.65 from we get to $6257.65 and set it to 6257.65
Added 33.4099999999999999 from now we add $33.4099999999999999 and set it to 6291.06
Added 37.24 from we add $37.24 and set it to 6328.30