in reply to Re^5: handling tab delimited files
in thread handling tab delimited files

Hey thanks a lot. This is working. I want to insert a header to the output file ? do you know how i can do that? I want the results to be printed in a new file. it has to be 7 X 10. how should i set values to 7 columns X 10 rows ?

Replies are listed 'Best First'.
Re^7: handling tab delimited files
by almut (Canon) on May 05, 2010 at 21:01 UTC
    I want to insert a header to the output file

    Just print it :)  — before printing the rows with the numbers:

    print "my header ...\n"; while (<FILE>){ ...
    I want the results to be printed in a new file.

    Either redirect the program's output (stdout) to a file using the shell, or explicitly open another file for output, and then print to that file handle:

    ... open OUTFILE, ">", "outfile.txt" or die $!; print OUTFILE "my header ...\n"; while (<FILE>){ print OUTFILE join("\t", map { $_ * $df * 50 } split /\t/), "\n"; }
    it has to be 7 X 10. how should i set values to 7 columns X 10 rows ?

    There isn't really anything to "set".  If you print 10 lines (rows) with each containing 7 tab separated values, you're done, essentially... i.e. the file will have 7 columns X 10 rows.  This would happen without further ado (with the code we have so far), provided the input file also has the same dimensions (which is seems to have (at least the columns), judging by your sample data).

      I was able to get the output in a new file... but header and the 7 X 10 does not work. no luck!!!
Re^7: handling tab delimited files
by toolic (Bishop) on May 05, 2010 at 20:52 UTC