use strict; use warnings; use Math::Round; my $test_value = 100.510; $test_value = fp_round( $test_value, 3 ); print "$test_value\n"; sub fp_round { my ( $val, $places ) = @_; return round( $val * ( 10 ** $places ) ) / ( 10 ** $places ); }