in reply to
EMPTY OUTPUT FILE GENERATED
A tab delimited file is one of the most horrific file formats that I could imagine. I cannot think of something worse than this. It is so hard that I won't even try to generate a tab delimited file, because my text editor just doesn't like to do that. But if you absolutely had to do that, the idea is shown below...
NEVER, NEVER EVER use a tab delimited file yourself - this is nasty stuff!
If you have fixed space fonts for this, then you cannot tell by just looking at this whether this is just spaces or even if there is a tab character in these lines!
123 aBVXC SAOMEWTRINOGN ABC
876 AsrdaDS some_bs 564
37897654 aofruafdouf abc
<c>
<c>
#!/usr/bin/perl -w
use strict;
open (IN, '<', "tab_file.txt") or die "$!";
while (<IN>)
{
my ($first_token) = split (/\s/, $_); #should be(/\t/, $_)
print $first_token,"\n";
}
__END__
123
876
37897654
tab_file.txt: (not really tabs)...
123 aBVXC SAOMEWTRINOGN ABC
876 AsrdaDS some_bs 564
37897654 aofruafdouf abc
When confronted with a tab delimted file, I would think about s/\t/|/g; or
the tr equivalent! The '|' character is is just a FAR, FAR better field delimiter than a tab. Many Databases are done this way. Second choice would be a CSV format. A tab delimited file just has all things bad going for it - sorry if you have to deal with one of these things. Don't make one yourself!