Transpose tab deliminated textfile with perl using Array::Transpose

2014-03-10T19:59:27

I have several huge textfiles which I need to transpose. I get stuck on the idea using Array::Transpose for that purpose - but somehow I can't come to an end... Here is my source code:

#!/usr/bin/perl

use warnings;
use strict;
use Array::Transpose;

my $eachline;
my $input=$ARGV[0];
my @array;

open (IN, "<$input") or die ("no such file!");
while(defined($eachline=<IN>))
{
   push @array, split(/\t/,$eachline);
}

my @array2=transpose(\@array);

I can not see, what is wrong with that idea, as the documentations says:

use Array::Transpose;
@array=transpose(\@array);

The error code says:

Can't use string ("") as an ARRAY ref while "strict refs" in use at /usr/local/share/perl/5.14.2/Array/Transpose.pm line 91, <IN> line 3.

I am almost new in programming, especially in Perl. I really don't understand what the error means. I am happy with any helpful answer!

Cheers, newbie!

Edit: What I have forgotten to say: My input file says:

Parameter1 \t Parameter2 \t .... ParameterXY \n 
Value1 \t Value2... 

and so on.

I want an output file that says:

Parameter1 \t Value1 \t .....ValueXY \n
Parameter2 \t Value2 \t......

Copyright License:
Author:「user3401516」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/22299488/transpose-tab-deliminated-textfile-with-perl-using-arraytranspose

About “Transpose tab deliminated textfile with perl using Array::Transpose” questions

I have several huge textfiles which I need to transpose. I get stuck on the idea using Array::Transpose for that purpose - but somehow I can't come to an end... Here is my source code: #!/usr/bin/...
I have started learning perl and like to try out new things. I have some problem in text processing. I have some text of the form, 0 1 2 3 4 5 6 7 8 9 10 6 7 3 6 9 3 1 5 2 4 6 I want to transpose
I have been searching around for some ways to transpose a large csv file using Perl, but can't get it right with my loops. There is a header row with 7 columns (I have 200+ columns actually). The ...
I think I my code was right but I still can not transpose my array do I code right for the variable of malloc transpose? int *arr = (int *)malloc(r * c * sizeof(int)); int *transpose = (int *)mallo...
I am newbie with Perl. I have an assignment to transpose rows into columns of a huge data. customers goods transportation ---------- ----- -------------- A, B, C, D ...
I have a set of data (26250) on one column, but I need them in rows of 175 values, on other words I need transpose them in 150 rows, and I have to do this for at least 10 files. I wondering if ther...
I'm wonder how can I undo my transpose operation. Let me be more specific in example: a = np.random.rand(25,32,11) b = a.transpose(2,0,1) c = b.transpose(??) ### Here I should set (1,0,2) # c == a
I am trying to transpose a Collection into an array. I'm not sure what's the method to do this. I think it's due to my lack of understanding in the eloquent operators/commands. I've been trying wi...
I have stored four images in cell array as 4 by 1 matrix. How to perform hermitian transpose of this matrix in matlab and then to perform this matrix with its hermitian transpose?
I've been stuck on this for a while. As an assignment I need to transpose this 2D array without using the built in transpose method, and without altering the function name / output. I feel like it

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.