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