in reply to Writing file

If you want to limit the precision of the log numbers, you can use a format spec in the print statement. %.3f means floating point with 3 decimal places. See below.
#usr/bin/perl -w use strict; while(<DATA>) { my($name, @num) = split; print $name; foreach my $num (@num) { printf " %.3f", log10($num); } print "\n" } sub log10 { my $n = shift; return log($n)/log(10); } =prints name1 3.171 3.157 3.164 3.160 3.021 3.032 3.036 3.022 name2 3.296 3.290 3.239 3.229 3.286 3.302 3.230 3.266 =cut __DATA__ name1 1481.100 1436.550 1460.410 1444.460 1049.120 1076.890 1085.500 1 +053.100 name2 1978.700 1949.910 1734.030 1694.530 1930.000 2005.530 1696.960 1 +844.810

Replies are listed 'Best First'.
Re^2: Writing file
by stavros (Novice) on Jun 23, 2011 at 20:16 UTC
    thank you very much for your valuable help.