Klaus Mock: Spalten sortieren

Beitrag lesen

Hallo,

my $c=2;
my @data0;
my @data1;
my @data2;
my @data3;
my @data4;
my @data5;
my $s=0;

while(<FILE>) {
   my @tmp=split / /,$_;
   $tmp[$t]="$tmp[$t]n$t";  #n$t als Index
   $data0[$s]=$tmp[0];
   $data1[$s]=$tmp[1];
   $data2[$s]=$tmp[2];
   $data3[$s]=$tmp[3];
   $data4[$s]=$tmp[4];
   $data5[$s]=$tmp[5];
   $s++;
}

Du solltest Dir unbedingt einmal http://www.perldoc.com/perl5.8.4/pod/perldsc.html bzw. http://www.perldoc.com/perl5.8.4/pod/perllol.html

Dann würde das ungefähr so aussehen (kann aber durchaus auhc abegwandelt werden;-)

my $c=2;
my @data;

while(<FILE>) {
    my @tmp=split / /,$_;
    $tmp[$t]="$tmp[$t]n$t";  #n$t als Index
    for($col = 0; $col<6;$col++) {
       $data[$col][$s]=$tmp[$col];
       }
    $s++;
    }

Und der Rest ist dann auch einfacher. Aber lies selbst.

Grüße
  Klaus