When I copied your data, I get single spaces instead of tab characters. Try to use
split as follows:
use strict;
use warnings;
my $df = 10;
while (<DATA>) {
chomp $_;
my @values = split;
foreach my $val (@values) {
my $DNA_conc = $val * $df * 50;
print $DNA_conc;
print "\n";
}
}
__DATA__
0.250 0.413 0.432 0.345 0.786 1.001 0.987
0.984 0.125 0.678 0.243 0.657 0.342 0.743
0.986 0.734 0.764 0.650 0.457 0.965 0.836
This is the output I get:
125
206.5
216
172.5
393
500.5
493.5
492
62.5
339
121.5
328.5
171
371.5
493
367
382
325
228.5
482.5
418
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.