Thread Sortieralgorithmus: (war: Sortieralgorythmus) (11 answers)
Opened by Jamthelaw at 2005-10-20 19:59

Ronnie
 2005-10-25 12:45
#59075 #59075
User since
2003-08-14
2022 Artikel
BenutzerIn
[default_avatar]
Code: (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
#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my %lut;
my $cur;
my %rev_lut;

while(<DATA>) {
chomp;
$cur = $1 if /(Gruppe\d+)/;
push @{$lut{$cur}}, $_ unless (/Gruppe/ or /^\s*$/);
}

print Dumper \%lut;

while (my ($k, $v) = each %lut) {
push @{$rev_lut{$_}}, $k for @$v;
}

print Dumper \%rev_lut;

_ _DATA_ _
Gruppe1
PC1
PC2
PC3

Gruppe2
PC2
PC4
PC5

Gruppe3
PC1
PC6

die Antwort von Taulmarill war schon die hundert Punkte Antwort :)

EDIT: _ _ DATA _ _ Bug *grmpf*\n\n

<!--EDIT|Ronnie|1130230150-->

View full thread Sortieralgorithmus: (war: Sortieralgorythmus)