apachi15 has asked for the wisdom of the Perl Monks concerning the following question:
I also liked this one because short and effective.open my $fh_in , '<', 'test1.txt' or die "Can not open file test1.txt: + $!"; open my $fh_out, '>', 'test2.txt' or die "Can not open file test2.txt: + $!"; while (<$fh_in>) { s/\s+/\t/g; print $fh_out "$_\n"; } close $fh_out; close $fh_in;
The codes do their job but still there is a problem in the 5th column (after syntenic)since there is not always an entry. This is an example of my text file:foreach my $line(@input) { $line =~ tr/ /\t/s; }
In the lines with no entry in the 5 th column there should be second TAB. I currently work with an if(...){then....} I hope it is clearer now, Thanks MartinMGI:1918918 381629 0610007C +21Rik 5 syntenic 51374 + C2orf28 2p23.3 B MGI:1918917 71667 0610007L +01Rik 5 syntenic F 55069 + C7orf42 7q11.21 C MGI:1923501 76251 0610007P +08Rik 13 syntenic B3 375748 + C9orf102 9q22.32 M MGI:1915571 58520 0610007P +14Rik 12 syntenic 11161 + C14orf1 14q24.3 B
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replacing spaces
by Corion (Patriarch) on Apr 07, 2009 at 11:56 UTC | |
by apachi15 (Initiate) on Apr 07, 2009 at 12:13 UTC | |
by Corion (Patriarch) on Apr 07, 2009 at 12:20 UTC | |
|
Re: Replacing spaces
by BrowserUk (Patriarch) on Apr 07, 2009 at 12:24 UTC | |
by apachi15 (Initiate) on Apr 07, 2009 at 12:47 UTC | |
by BrowserUk (Patriarch) on Apr 07, 2009 at 13:37 UTC | |
by apachi15 (Initiate) on Apr 08, 2009 at 09:14 UTC | |
by BrowserUk (Patriarch) on Apr 08, 2009 at 10:11 UTC | |
|
Re: Replacing spaces
by Anonymous Monk on Apr 07, 2009 at 11:56 UTC | |
by apachi15 (Initiate) on Apr 07, 2009 at 12:16 UTC | |
by Anonymous Monk on Apr 07, 2009 at 12:57 UTC | |
|
Re: Replacing spaces
by swampyankee (Parson) on Apr 07, 2009 at 12:57 UTC |