in reply to handling tab delimited files

print is a fabulous debugging tool. Show us what $val and $df are:
use warnings; print " Enter the dilution factor. \n"; chomp ($df = <STDIN>); open FILE, "45well.txt" or die $!; while (<FILE>){ chomp $_; @values = split('\t', $_); $val = @values; foreach $val (@values){ print "df >>>$df<<<\n"; print "val >>>$val<<<\n"; $DNA_conc = $val * $df * 50 ; print $DNA_conc; print"\n"; } } close (FILE);

That's Tip #2 from the Basic debugging checklist.

Replies are listed 'Best First'.
Re^2: handling tab delimited files
by shaludr (Initiate) on May 05, 2010 at 17:05 UTC
    $df = is the user input value. so if i enter 10 $df = 10. $ val is giving the output as 111111. so something is wrong here. the file looks like this
    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
      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