Thread Hashes (27 answers)
Opened by BrownWolf at 2003-08-15 22:03

format_c
 2003-08-15 22:28
#53414 #53414
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
Also irgendwie machst du es dir ganz schön kompliziert. Aber hier trotzdem die Lösung die mir grad so einfällt:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl

my %hash;
my &#36name="format_c";
my &#36wonid = 29473462;
my &#36weapon= "M1A1";

for (0..3) {
    &#36hash{"&#36name"}{"&#36wonid"}{"&#36weapon"}++;
}

for my &#36name (keys %hash) {
    for my &#36wonid (keys %{&#36hash{&#36name}}) {
     for (keys %{&#36hash{&#36name}{&#36wonid}}) {
        print "&#36name => &#36wonid => &#36_\n";
       print "&#36name => &#36wonid => connects &#36hash{&#36name}{&#36wonid}{&#36_}\n";
     }
    }

}


Ich würde dir aber eher eine Datenstruktur wie diese empfehlen, da lebt es sich leichter.
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
my %hash = (
    format_c => {
       wonid => 826382,
       weapon => 'M1A1',
       connects => 3
       },
    Browswolf => {
       wonid => 826351,
       weapon => 'AK47',
       connects => 5
       }
)


Gruß Alex\n\n

<!--EDIT|format_c|1060972295-->

View full thread Hashes