------------8<------------------ I'm trying to truncate a number, 10.25233006477356, to 6 decimal points. E.g. 10.252330. I don't need to round the number, I just want it to drop everything after the 6th decimal point. This should be easy, but I'm drawing a blank. ------------8<------------------
In the spirit of TMTOWTDI, and the with the subtle elegance of one liners try: use strict; use warnings; my $pi = 22 / 7; print "pi is about $pi\n"; $pi =~ s/^(\d+)\.(\d+)$/"$1." . substr($2, 0, 6)/e; print "now pi is about $pi\n"; __END__ Just in _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
