[Milan-pm] incolonnare dati

Oha oha at oha.it
Thu Nov 5 07:12:49 PST 2009


un po spaghetti ma magari puo' esser uno spunto:

use strict;
use warnings;

use Data::Dumper;

my %data;
my %cols;
while(<DATA>)
{
    chomp;
    my @cols = split /s+/;
    my $first = shift @cols or next;
    my $second = shift @cols;
    my %other = map { /([^(]+)((d+))*?/; $cols{$2}++; ($2,$1); } @cols;
    $other{__perc} = $second;
    $data{$first} = %other;
}

foreach my $k (sort keys %data)
{
    my $other = $data{$k};
    print $k, "t", $other->{__perc}, "t";
    foreach my $c (sort { $a <=> $b } keys %cols) {
        my $v = $other->{$c};
        print $v ? "$v($c)t" : "-t";
    }
    print "n";
}

__DATA__
1opj-A 100.0 M309(67)* F401(159)* F336(94)* I379(137)* A399(157)* K290(48)* I332(90)* Y272(30)* V275(33)* A288(46)* L267(25)* V318(76)* H380(138)* L389(147)* T334(92) D400(158) M337(95) E305(63)
2hyy-A 99.2 F382(147)* M290(55)* F317(82)* I360(125)* Y253(19)* A269(35)* H361(126)* L248(14)* A380(145)* K271(37)* V289(54)* I313(78)* L370(135)* V256(22)* I293(58)* V299(64)* D381(146) T315(80) M318(83) E286(51)
2pl0-A 48.3 Y318(88)* F383(153)* A271(41)* M319(89)* I361(131)* M292(62)* I314(84)* A381(151)* K273(43)* V301(71)* H362(132)* V259(29)* L291(61)* D382(152) T316(86) E288(58)


 



More information about the Milan-pm mailing list