On Thu, Jul 21, 2011 at 8:17 AM, Nathalie Conte <n...@sanger.ac.uk> wrote:

> I forgot to say that the extra lines are empty... but I don't understand
> why they are there :)
>
>
That's rather simpler, since there's nothing in the program that could cause
double output (unless you ran it twice :P).
The issue is that you read in lines, and the end of each line has a \n. So
assuming there's no tab after each -1, $line[3] will actually contain "-1\n"
- and your print also has a \n. So there's your empty line. Either add
chomp; before the line with the slit, or remove the newline from the print.

Also, a comment on your code:
  print OUT $line[0],"\t",$line[1],"\t",$line[2],"\t",$line[3],"\n";

That's rather unwieldy, isn't it? You could simplify it a bit by taking
advantage of interpolation, like this:

print OUT "$line[0]\t$line[1]\t$line[2]\t$line[3]";

But that's still a mouthful, so you could use join[0] instead:

print OUT join "\t", @line;

[0] http://perldoc.perl.org/functions/join.html

Reply via email to