sub trunc { my ($float, $precision) = @_[0..1]; my @comp = split /\./, $float; chop $comp[1] while length($comp[1]) > $precision; #trim $comp[1].='0' for (length($comp[1])..$precision-1); #pad return "$comp[0].$comp[1]"; } printf ("%5.2f", trunc($yearlyamount/52,2));