sub round ($$) { sprintf "%.$_[1]f", $_[0]; } my $rounded = round 3.165232, 2;