in reply to How to add column into array from delimited tab file
The problem area is when you open and write to the output file WITHIN the read loop for each row.
You need to move the output file open and Write OUTSIDE the file read loop, something like this:
(Made some adjustments to localize the file handle, and use the "3 argument" open - see other writeups to understand why this is a good idea.# Outside the read loop, after closing input file.... mkdir "$pathname" or die "Error couldn't create new Directory"; open my $OUT1, ">", "$pathname/column.txt" or die "error couldn't open + output file"; print $OUT1 "$_\n" for @data1; close $OUT1;
What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
-Larry Wall, 1992
|
|---|