Thread Top der der Länder der User
(14 answers)
Opened by stb2050 at 2003-08-17 19:37
Habs ein wenig standardiesiert und optimiert.Entweder du benutzt immer $_ oder ne Elementvariable, sonst verwirrt das nur.
Und du brauchst die Daten nicht zwischenzuspeichern, ist nur unnötige verschwendeter speicher. my %hash = (); my @sortiert = (); my @laender = (); foreach (@userdaten) { my ($ort, $land) = split(/\|\|\|/, $_); $hash{$land}++; } @sortiert = sort { $hash{$b} <=> $hash{$a} } keys %hash; foreach(@sortiert) { push(@laender, "$_|||$hash{$_}\n"); } for(0..9) { print "$laender[$_]<br>\n"; } Edit: Wie kann ich das direkt ausgeben: @sortiert = sort { $hash{$b} <=> $hash{$a} } keys %hash; hatte das mal gelöst, wie oben bereits erwähnt komm aber nicht mehr drauf :(\n\n <!--EDIT|SirLant|1061162932--> --Programming today is a race between Software Enginers striving to build bigger and better idiot-proof Programs,
and the Universe trying to produce bigger and better idiots. So far, the Universe is winning! |