Thread array-hash-Struktur zusammenbasteln (8 answers)
Opened by bieber at 2009-07-23 10:44

MatthiasW
 2009-07-23 11:00
#123485 #123485
User since
2008-01-27
367 Artikel
BenutzerIn
[default_avatar]
Folgendes sollte das tun, was du möchtest(nicht getestet):
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
my $data;
ROW: while ( my @line = $q->fetchrow_array ) {
    for my $i ( @$data ) {
        if ( $i->{SERVER} eq $line[0] ) {
            push @{ $i->{DATENBANKLISTE} }, { DATENBANK => $line[1] };
            next ROW;
        } # if
    } # for
    push @$data, { SERVER => $line[0], DATENBANKLISTE => [{ DATENBANK => $line[1] }] };
} # while

Aber ich halte die Struktur in der du die Daten ablegst nicht für angebracht. Ein HoA würde es doch auch tun, oder?
edit: Entschulde, hatte übersehen, dass du die Daten ja an HTML::Template weiterreichst.
Code (perl): (dl )
1
2
3
4
5
# also brauchst du das hier nicht ;)
my $data = {};
while ( my @line = $q->fetchrow_array ) {
    push @{ $data->{$line[0]} }, $line[1];
} # while

MfG
Last edited: 2009-07-23 11:03:43 +0200 (CEST)
perl -E'*==*",s;;%ENV=~m,..$,,$&+42;e,$==f;$"++for+ab..an;@"=qw,u t,,print+chr;sub f{split}say"@{=} me"'

View full thread array-hash-Struktur zusammenbasteln