in reply to Why is there only one column in the output file?

toolic is correct.

you probably want something like this

while(<IN>){ my $line = $_; unless ($line =~ /\S/) { print STDERR "Skipping line $. (blank)\n"; next; } my @fields = split /\t/,$line; unless (@fields >= 10) { print STDERR "Error: line $.: less than 10 fields: $_\n"; } . . .

Replies are listed 'Best First'.
Re^2: Why is there only one column in the output file?
by jwkrahn (Abbot) on Apr 05, 2012 at 21:46 UTC
    you probably want something like this

    while(<IN>){
        my $line = $_;

    No.    Nobody wants something like that.

    Why store the same value in two different variables when you only use one variable inside the loop.

    Perhaps you meant:

    while ( my $line = <IN> ) {

      jwkrahn, you miss the point.

      The main point was to check for and weed out blank lines and those which do not contain enough fields. I agree it would be better to assign the $line var in the while statement as well; I wrote it that way to change the OP's code as little as possible and focus on the input validation pieces.