lomSpace has asked for the wisdom of the Perl Monks concerning the following question:
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:
Your wisdom is appreciated!
LomSpace
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Where is my output stream to a file going?
by davido (Cardinal) on Mar 30, 2011 at 05:56 UTC | |
Re: Where is my output stream to a file going?
by biohisham (Priest) on Mar 30, 2011 at 07:45 UTC | |
by lomSpace (Scribe) on Mar 30, 2011 at 15:08 UTC | |
by davido (Cardinal) on Mar 30, 2011 at 16:40 UTC | |
Re: Where is my output stream to a file going?
by wind (Priest) on Mar 30, 2011 at 05:28 UTC | |
Re: Where is my output stream to a file going?
by samarzone (Pilgrim) on Mar 30, 2011 at 07:08 UTC | |
Re: Where is my output stream to a file going?
by Marshall (Canon) on Mar 30, 2011 at 23:29 UTC |
Back to
Seekers of Perl Wisdom