After I split my data, when I try to print the output to a tab delimited textfile, I have problem getting the output I want.
Output that I want:
A776 762.81 0.76 1 1 1 1 1 1 1
A872 762.91 1.23 2 2 2 2 2 2 2
.
.
.
What I get is :
A776 762.81 0.76 1
A776 762.81 0.76 1
A776 762.81 0.76 1
A776 762.81 0.76 1
A776 762.81 0.76 1
A776 762.81 0.76 1
A776 762.81 0.76 1
A872 762.91 1.23 2
A872 762.91 1.23 2
A872 762.91 1.23 2
A872 762.91 1.23 2
A872 762.91 1.23 2
A872 762.91 1.23 2
A872 762.91 1.23 2
Here's part of my code:
while(my $header_line = <CURINFILE>)
{
my @headers = split/\s+/, $header_line;
push @full_data , [split /\s+/, $_] while (<CURINFILE>);
for my $arr_ref1 (@full_data)
{
for my $arr_ref2(@full_data)
{
for my $index (3..$#headers)
{
my $ratio1 = $$arr_ref2[$index]/$$arr_ref1[$index]; #
+ this is the part where 1 and 2 is outputted.
my $ratio = sprintf("%.4f", $ratio1);
print OUT1 "$$arr_ref2[0]\t$$arr_ref1[0]\t$$arr_ref2[1]\t$$ar
+r_ref2[2]\t\t$ratio1\n";
}
}
}
}
How do I get $ratio1 to be formatted in tab instead of newline?
Advice appreciated!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.