Hello PerlMonks!
I have a wierd problem. I am able to read the file, process it, and print to a file only
when I include the data in the script using __DATA__. When I read into the IN
filehandle and write to an out file I get a blank file. Any Ideas?
The following is the code:

#!/usr/bin/perl -w use strict; use Data::Dumper; #open file for reading open(IN,"/Users/me/Desktop/CCDS.current.txt") or die " Can't open file +: $!"; #open out file for writing open(OUT, ">/Users/me/Desktop/withdrawndata.txt"); #remove the header my $firstline= <IN>; chomp $firstline; while(<IN>){ chomp; # remove the newline character my @fields = split/\t/; # split the file into columns where eachli +ne in it #populates and array for that column. if($fields[5] =~ m/Withdrawn/){ # print eachline that has "Withdra +wn" in field[5] print OUT "$_\n"; # print to file } } close(IN); close(OUT); __DATA__ #chromosome nc_accession gene gene_id ccds_id ccds_stat +us cds_strand cds_from cds_to 1 NC_000001.8 NCRNA00115 79854 CCDS1.1 Withdrawn - + 801942 802433 1 NC_000001.10 SAMD11 148398 CCDS2.2 Public + 861 +321 879532 1 NC_000001.10 NOC2L 26155 CCDS3.1 Public - 88007 +3 894619 1 NC_000001.10 PLEKHN1 84069 CCDS4.1 Public + 901 +911 909954 1 NC_000001.10 HES4 57801 CCDS5.1 Public - 934438 + 935352 1 NC_000001.10 ISG15 9636 CCDS6.1 Public + 948953 + 949857 1 NC_000001.10 C1orf159 54991 CCDS7.2 Public - 10 +18272 1026922 1 NC_000001.10 TTLL10 254173 CCDS8.1 Public + 111 +5433 1120521 1 NC_000001.10 TNFRSF18 8784 CCDS9.1 Public - 113 +8970 1141950 1 NC_000001.10 TNFRSF18 8784 CCDS10.1 Public - 11 +39223 1141950 1 NC_000001.10 TNFRSF4 7293 CCDS11.1 Public - 114 +6934 1149506

Your wisdom is appreciated!
LomSpace

In reply to Where is my output stream to a file going? by lomSpace

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.