my $num = 12345.678; # a total of 9 characters if (length $num > 8) { if ($num =~ /\./) # If there's a decimal point { # Put it to seven significant figures } else { # Put it to eight significant figures } }