use POSIX qw(floor); my $unit = 0.05; my $number = 12.34567; my $rounded = $unit * floor(0.5 + $number / $unit);