![]() |
|< 1 2 3 >| | ![]() |
28 Einträge, 3 Seiten |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/perl use strict; use warnings; my $file = 'input.txt'; my %hash; open my $fh, '<', $file or die $!; while( my $line = <$fh> ){ chomp $line; my @zahlen = split /,/, $line; for my $i ( 0..$#zahlen ){ push @{$hash{$i}}, $zahlen[$i]; } } close $fh; for my $j ( sort{ $a <=> $b }keys %hash ){ print join("\t", @{ $hash{$j} }),"\n"; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
use strict;
use warnings;
my @output;
while ( my $line = <> ) {
my @zahlen = split /\s+/, $line;
my $row = 0;
for my $wert ( @zahlen ) {
push @{$output[$row++]}, $wert;
}
}
for my $row ( @output ) {
print "@$row\n";
}
1
2
3
4
5
6
7
8
9
sidburn@sid:~/perl$ ./zahlen.pl zahlen.txt
10 20 30
20 30 40
30 40 50
40 50 60
50 60 70
60 70 80
70 80
80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl
use strict;
use warnings;
my @output;
my $col = 0;
while ( my $line = <> ) {
my @zahlen = split /\s+/, $line;
my $row = 0;
for my $wert ( @zahlen ) {
$output[$row++][$col] = $wert;
}
$col++;
}
for my $row ( @output ) {
for my $wert ( @$row ) {
print $wert || 'N/A', ' ';
}
print "\n";
}
1
2
3
4
5
6
7
8
9
sidburn@sid:~/perl$ ./zahlen.pl zahlen.txt
10 20 30
20 30 40
30 40 50
40 50 60
50 60 70
60 70 80
N/A 80 90
N/A N/A 100
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); }
![]() |
|< 1 2 3 >| | ![]() |
28 Einträge, 3 Seiten |