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

In reply to Re: Writing file by Marshall
in thread Writing file by stavros

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.