in reply to hash sort problems
my %server_hash = ( SERVER1 => {tag => 53, ADMINS => undef, ADMINSGRP += undef}, SERVER2 => {tag => 1, ADMINS = "account1", ADMINSGRP = ["gl +obal1","global2"]}, SERVER3 => {tag => 1236 ADMINS = "account2", ADMI +NSGRP = ["global1","global2"]}, SERVER4 => {tag => 1236 ADMINS = "acc +ount1", ADMINSGRP = ["global1","global2"]} ) )
foreach my $server ( sort {$my_server_hash {$a} cmp $my_server_hash +{$b} && $my_server_hash{$a}{tag} <=> $my_server_hash{$b} +{tag} } keys %my_server_hash) { my $member = $my_server_hash{$server}{ADMINS}; $servercount++; $access = $my_server_hash{$server}{tag}; if ($access == 1) { $comment = ""; $color="#99FF33"; } elsif ($member =~ s/$account/FOUND:$account/i && $acces +s !=1) { # this means password is wrong! $color = "#FF3366"; $comment = "<a name=\"password_wrong\"><b>$ +account password is wrong! </b></a>"; } elsif ($access == 53) { $comment = " <a name=\"unavailable\"> <font color + = \"white\"> <b>machine unavailable! <br></b></a> "; $color = "#996666"; } elsif($my_server_hash{$server}{ADMINS}) { $comment = " <a name=\"no_account\"><b> $ac +count account does not exist</b> </a>"; $color = "#FF3333"; } else { $comment = " <a name=\"unknown\"> <font co +lor = \"white\"> <b>unable to access! <br></b></a> "; $color = "#FF66CC"; } server_data_row("19%",$color, "27%", "Verdana, Arial, Helvetica, sa +ns-serif","4",$server,$htm_pass_handle); server_data_row("12%",$color, "27%", "Courier New, Courier, mono"," +2","$member",$htm_pass_handle); server_data_row("69%",$color, "27%", "Courier New, Courier, mono"," +3",$access."<b> $comment</b>",$htm_pass_handle,"</tr>"); } # foreach server
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: hash sort problems
by dmmiller2k (Chaplain) on Apr 19, 2002 at 13:53 UTC |