Hello,

i need your help in a small programme that i want to create. i have a file which contain the following

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 name3 ...

and i want to write it as it is in a new file by only replacing the values with log(value)

so i use this programme

my $Name = ""; my $Value1 = 0; my @files = glob ('*.txt'); sub log10 { my $n = shift; return log($n)/log(10); } open (MYFILE, '>data.txt'); foreach my $file (@files) { #print "$file\n"; $test = "$file"; open (TEST,"$test") || die "couldn't open the file YEASTFASTA:$!"; while (<TEST>) { my $line = $_; if ($_=~/^\d+[_]\w+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+.*/) { #$Name = $1; $Value1 = $2; $LogValue = log10($Value1); print MYFILE "$LogValue"; #print "d $LogValue \n"; } print MYFILE "$_"; } close TEST || die "can't close:$!"; close (MYFILE); }

and the output i take is

1.37852508154491 name1 23.907 15.022 25.234 22.573 21.541 13.972 25.07 +6 17.099 YLR331C 3.17058438193919 name2 1481.100 1436.550 1460.410 1444.460 1049.120 10 +76.890 1085.500 1053.100

so my point is how can i place the value 1.3785250815449 (which is the log(23.907)) not in the begging of the line but instead of the value 23.907, that means that i want this output

name1 1.3785250815449 log(value) log(value)...(log of all the values) name1 log(value) log(value)...(log of all the values)

Thanks in advance for your time.


In reply to 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.