Thread formatierte Datenausgabe (27 answers)
Opened by Norden at 2007-06-06 13:25

topeg
 2007-06-08 14:27
#77328 #77328
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Ungetestet:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
use strict;
use warnings;

my $filename_in='/pfad/datei.in';
my $filename_out='/pfad/datei.out';

my @MultFact=(); # ????????????

# zu lesende Datei
{
  local $/ = "\r\n";
  open(IN, '<', $filename_in) or die "$filename_in: $!";
  binmode(IN);
  my @in_liste=<IN>;
  close(IN);

 # Daten umwandeln
  for(my $c=0;$c<@in_liste;$c++)
  {
    my $l=$in_liste[$c];
    chomp($l);
    my @arr=unpack('C*',$_);
    map{ $_*=$MultFact[$c] }@arr;
    $in_liste[$c]=\@arr;
  }

  # Zeile<>Spalte tauschen
  my $out_liste=[];
  for(my $scount=0; $scount<@{$in_liste[0]]; $scount++)
  {
    for (my $lcount=0; $lcount<@in_liste; $lcount++)
    {
      $$out_liste[$scount]=[] if(ref($$out_liste[$scount]) ne 'ARRAY'); # ich weiß nicht nötig...
      $$out_liste[$scount][$lcount]=$liste[$lcount][$scount];
    }
  }

  # alles zusammenfügen:
  map{$_=join("\t",@$_)}@$out_liste;
  $out_liste=join("\n",@$out_liste);

  # Ergebnisse hier hineinschreiben
  open(OUT, '>>' ,$filename_out) or die "$filename_out: $!";
  print OUT $out_liste;
  close(OUT);
}

View full thread formatierte Datenausgabe