in reply to Re: manipulating a data table
in thread manipulating a data table

Hi, The perl code worked really well and for the columns more than 2 i can just use
for my $c(1..16)
Can you explain me a little bit what some portions of your code is doing. In the while loop you are adding each line of the input file as an array ref into an array named input
while (<>) { chomp; my @s = split /\t/,$_; push @input ,\@s; }
Can you explain me the use of map and what exactly is that line doing? Also can you right this statement in the loop form rather than one line. It is easy to understand
$output[$_][$c] = $x++ for sort { $input[$b][$c] <=> $input[$a][$c] } +0 .. $#input;
Thanks

Replies are listed 'Best First'.
Re^3: manipulating a data table
by choroba (Cardinal) on Aug 16, 2016 at 20:29 UTC
    To see what structure the first loop creates, use
    use Data::Dumper; print Dumper(\@input);

    You'll get the following output:

    The map line

    my @output = map [ $_->[0] ], @input;

    creates the output, it maps each element of @input to a reference to a new array containing its first element, i.e.

    The last cited line sorts the array indices (that represent input line numbers) by $c-th element (reversed), and than sets $c-th element of the output to be the order number. Thus, the first iteration processes the second column:

    and the second one the next one:

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,