GnaData/Transpose.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 37 CC 2 SCAR 15.4
CC
2
Cov
0%
transpose
6.0
BEGIN
2.0
CRAP 4.7
1 package GnaData::Transpose;
2 use strict;
3  
4 sub transpose {
5 my ($inh, $outh) = @_;
6 my ($row) = 0;
7 my ($maxcol) = 0;
8 my ($line) = 0;
9 my ($store) = [[]];
10
11 while ($line = <>) {
12 chop $line;
13 my (@items) = split (/\t/, $line);
14 my ($col, $item);
15 $col = 0;
16 foreach $item (@items) {
17 $store->[$row]->[$col] = $item;
18 $col++;
19 }
20 if ($col > $maxcol) {
21 $maxcol = $col;
22 }
23 $row++;
24 }
25
26 my ($i,$j);
27 for ($i=0; $i < $maxcol; $i++) {
28 my (@items) = ();
29 for ($j=0; $j < $row; $j++) {
30 push (@items, $store->[$j]->[$i]);
31 }
32 $outh->print(join("\t", @items), "\n");
33 }
34 }
35 1;